[libvirt] [PATCH] Fix compilation of virt-aa-helper.c
by Matthias Bolte
Commit 5073aa994af460e775cb3e548528e28d7660fcc8 added an additional
'}' to a case block that messed up the block structure of the get_files
function.
---
src/security/virt-aa-helper.c | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c
index 3c8b49a..1b0b2cd 100644
--- a/src/security/virt-aa-helper.c
+++ b/src/security/virt-aa-helper.c
@@ -851,7 +851,6 @@ get_files(vahControl * ctl)
if (rc != 0)
goto clean;
break;
- }
}
/* TODO: update so files in /sys are readonly
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: {
--
1.6.3.3
14 years, 10 months
[libvirt] newer gnulib: requires several header-include fixes
by Jim Meyering
A week or two ago, upstream gnulib was fixed to be more namespace friendly
in how it creates replacement headers. For some of its replacements
(e.g., <stdio.h>, used via gnulib/lib/stdio.h), it would unnecessarily
include another header, e.g., <stdlib.h>. That would make it so that
an application using gnulib's <stdio.h> could think it's fine *not*
to include stdlib.h, even though it uses a function like exit whose
declaration usually requires an explicit inclusion of <stdlib.h>.
[the example above is made up -- in reality it was more subtle]
Well, now, those excess inclusions have been removed, and when I upgraded
libvirt to use the latest gnulib, I saw many compilation failures due
to missing #include directives.
This series fixes the problems, then adds a change-set to update to the
latest gnulib.
Here are the one-line summaries:
util.c: include required header, no longer masked by gnulib
cpu_x86_data.h: include required header
vbox: include required headers
esx_vi_types.c: include required headers
storage_backend.h: include required headers
build: update gnulib submodule to latest
>From ed2e5140a5a5529ca19e730d061f6d5b3872bb7f Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Fri, 15 Jan 2010 10:31:23 +0100
Subject: [PATCH 1/6] util.c: include required header, no longer masked by gnulib
Until recently, some gnulib-generated replacement headers
included *other* headers that were not strictly necessary,
thus masking the need in this file for an explicit <stdlib.h>.
* src/util/util.c: Include <stdlib.h> for declarations of e.g.,
strtol, random_r, getenv, etc.
---
src/util/util.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/src/util/util.c b/src/util/util.c
index 45ca657..67fae00 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -1,7 +1,7 @@
/*
* utils.c: common, generic utility functions
*
- * Copyright (C) 2006, 2007, 2008, 2009 Red Hat, Inc.
+ * Copyright (C) 2006-2010 Red Hat, Inc.
* Copyright (C) 2006 Daniel P. Berrange
* Copyright (C) 2006, 2007 Binary Karma
* Copyright (C) 2006 Shuveb Hussain
@@ -28,6 +28,7 @@
#include <stdio.h>
#include <stdarg.h>
+#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
--
1.6.6.556.gd6679
>From c920cd6ae55e4b89aa32c7303ed206a83071f5c0 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Fri, 15 Jan 2010 10:33:32 +0100
Subject: [PATCH 2/6] cpu_x86_data.h: include required header
* src/cpu/cpu_x86_data.h: Include <stdint.h>.
---
src/cpu/cpu_x86_data.h | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/src/cpu/cpu_x86_data.h b/src/cpu/cpu_x86_data.h
index 8b09d23..25ee2a5 100644
--- a/src/cpu/cpu_x86_data.h
+++ b/src/cpu/cpu_x86_data.h
@@ -1,7 +1,7 @@
/*
* cpu_x86_data.h: x86 specific CPU data
*
- * Copyright (C) 2009 Red Hat, Inc.
+ * Copyright (C) 2009-2010 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -24,6 +24,8 @@
#ifndef __VIR_CPU_X86_DATA_H__
#define __VIR_CPU_X86_DATA_H__
+#include <stdint.h>
+
struct cpuX86cpuid {
uint32_t function;
uint32_t eax;
--
1.6.6.556.gd6679
>From 5efa5755bd38f0e7fb0f802c21dbd798e49ba5a3 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Fri, 15 Jan 2010 10:35:41 +0100
Subject: [PATCH 3/6] vbox: include required headers
* src/vbox/vbox_driver.c: Include <stdint.h> <unistd.h> <sys/types.h>.
---
src/vbox/vbox_driver.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/src/vbox/vbox_driver.c b/src/vbox/vbox_driver.c
index ad5f239..ef3eb4b 100644
--- a/src/vbox/vbox_driver.c
+++ b/src/vbox/vbox_driver.c
@@ -28,6 +28,10 @@
#include <config.h>
+#include <stdint.h>
+#include <unistd.h>
+#include <sys/types.h>
+
#include "internal.h"
#include "datatypes.h"
--
1.6.6.556.gd6679
>From b860fa5ed20cb54c56f50e25b40a9864b9ff4b60 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Fri, 15 Jan 2010 10:37:03 +0100
Subject: [PATCH 4/6] esx_vi_types.c: include required headers
* src/esx/esx_vi_types.c: Include <stdint.h>.
---
src/esx/esx_vi_types.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/src/esx/esx_vi_types.c b/src/esx/esx_vi_types.c
index 8c5b17b..c042e89 100644
--- a/src/esx/esx_vi_types.c
+++ b/src/esx/esx_vi_types.c
@@ -22,6 +22,7 @@
#include <config.h>
+#include <stdint.h>
#include <libxml/parser.h>
#include <libxml/xpathInternals.h>
--
1.6.6.556.gd6679
>From b57e46d562501d449f5e56bdf780496899494bf4 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Fri, 15 Jan 2010 10:38:36 +0100
Subject: [PATCH 5/6] storage_backend.h: include required headers
* src/storage/storage_backend.h: Include <stdint.h>.
---
src/storage/storage_backend.h | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/src/storage/storage_backend.h b/src/storage/storage_backend.h
index 88c6161..1c38eeb 100644
--- a/src/storage/storage_backend.h
+++ b/src/storage/storage_backend.h
@@ -1,7 +1,7 @@
/*
* storage_backend.h: internal storage driver backend contract
*
- * Copyright (C) 2007-2008 Red Hat, Inc.
+ * Copyright (C) 2007-2010 Red Hat, Inc.
* Copyright (C) 2007-2008 Daniel P. Berrange
*
* This library is free software; you can redistribute it and/or
@@ -24,6 +24,7 @@
#ifndef __VIR_STORAGE_BACKEND_H__
#define __VIR_STORAGE_BACKEND_H__
+#include <stdint.h>
#include "internal.h"
#include "storage_conf.h"
--
1.6.6.556.gd6679
>From e2617c6132f1da930f3c52926e71ec79a80dde1f Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Fri, 15 Jan 2010 10:23:22 +0100
Subject: [PATCH 6/6] build: update gnulib submodule to latest
---
.gnulib | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/.gnulib b/.gnulib
index 3fd9a2d..4c52807 160000
--- a/.gnulib
+++ b/.gnulib
@@ -1 +1 @@
-Subproject commit 3fd9a2df88c558b27be3a585ca2978dbf9b5da53
+Subproject commit 4c52807f41f238cf0e352317b2dc54f9ba0f0c4f
--
1.6.6.556.gd6679
14 years, 10 months
[libvirt] [PATCH] xen: do not report a write-to-Xen-daemon failure as a read failure
by Jim Meyering
FYI, pushed as obvious...
>From 02765872876ba8a820a5047f664da8a7b870b7b9 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Fri, 15 Jan 2010 10:22:08 +0100
Subject: [PATCH] xen: do not report a write-to-Xen-daemon failure as a read failure
* src/xen/xend_internal.c (wr_sync): Correct the diagnostic.
---
src/xen/xend_internal.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c
index d9bfa15..9c5127f 100644
--- a/src/xen/xend_internal.c
+++ b/src/xen/xend_internal.c
@@ -196,11 +196,11 @@ wr_sync(virConnectPtr xend, int fd, void *buffer, size_t size, int do_read)
if (do_read)
virXendError(xend, VIR_ERR_INTERNAL_ERROR,
"%s", _("failed to read from Xen Daemon"));
else
virXendError(xend, VIR_ERR_INTERNAL_ERROR,
- "%s", _("failed to read from Xen Daemon"));
+ "%s", _("failed to write to Xen Daemon"));
return (-1);
}
offset += len;
--
1.6.6.556.gd6679
14 years, 10 months
[libvirt] [PATCH v2] Implement path lookup for USB by vendor:product
by Cole Robinson
Based off how QEMU does it, look through /sys/bus/usb/devices/* for
matching vendor:product info, and if found, use info from the surrounding
files to build the device's /dev/bus/usb path.
This fixes USB device assignment by vendor:product when running qemu
as non-root (well, it should, but for some reason I couldn't reproduce
the failure people are seeing in [1], but it appears to work properly)
[1] https://bugzilla.redhat.com/show_bug.cgi?id=542450
v2:
Drop 'bus.addr only' checks in security drivers
Use various util helpers
Signed-off-by: Cole Robinson <crobinso(a)redhat.com>
---
po/POTFILES.in | 1 +
src/qemu/qemu_driver.c | 9 +--
src/security/security_selinux.c | 25 ++++-----
src/security/virt-aa-helper.c | 32 +++++------
src/util/hostusb.c | 110 +++++++++++++++++++++++++++++++++++++-
src/util/hostusb.h | 4 +-
6 files changed, 141 insertions(+), 40 deletions(-)
diff --git a/po/POTFILES.in b/po/POTFILES.in
index c9c78b6..3b82a74 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -55,6 +55,7 @@ src/uml/uml_conf.c
src/uml/uml_driver.c
src/util/bridge.c
src/util/conf.c
+src/util/hostusb.c
src/util/json.c
src/util/logging.c
src/util/pci.c
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index deb8adc..f03ce91 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -2105,14 +2105,11 @@ static int qemuDomainSetHostdevUSBOwnership(virConnectPtr conn,
struct qemuFileOwner owner = { uid, gid };
int ret = -1;
- /* XXX what todo for USB devs assigned based on product/vendor ? Doom :-( */
- if (!def->source.subsys.u.usb.bus ||
- !def->source.subsys.u.usb.device)
- return 0;
-
usbDevice *dev = usbGetDevice(conn,
def->source.subsys.u.usb.bus,
- def->source.subsys.u.usb.device);
+ def->source.subsys.u.usb.device,
+ def->source.subsys.u.usb.vendor,
+ def->source.subsys.u.usb.product);
if (!dev)
goto cleanup;
diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c
index 000bc8a..cb585ed 100644
--- a/src/security/security_selinux.c
+++ b/src/security/security_selinux.c
@@ -481,20 +481,17 @@ SELinuxSetSecurityHostdevLabel(virConnectPtr conn,
switch (dev->source.subsys.type) {
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB: {
- if (dev->source.subsys.u.usb.bus && dev->source.subsys.u.usb.device) {
- usbDevice *usb = usbGetDevice(conn,
- dev->source.subsys.u.usb.bus,
- dev->source.subsys.u.usb.device);
+ usbDevice *usb = usbGetDevice(conn,
+ dev->source.subsys.u.usb.bus,
+ dev->source.subsys.u.usb.device,
+ dev->source.subsys.u.usb.vendor,
+ dev->source.subsys.u.usb.product);
- if (!usb)
- goto done;
+ if (!usb)
+ goto done;
- ret = usbDeviceFileIterate(conn, usb, SELinuxSetSecurityUSBLabel, vm);
- usbFreeDevice(conn, usb);
- } else {
- /* XXX deal with product/vendor better */
- ret = 0;
- }
+ ret = usbDeviceFileIterate(conn, usb, SELinuxSetSecurityUSBLabel, vm);
+ usbFreeDevice(conn, usb);
break;
}
@@ -556,7 +553,9 @@ SELinuxRestoreSecurityHostdevLabel(virConnectPtr conn,
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB: {
usbDevice *usb = usbGetDevice(conn,
dev->source.subsys.u.usb.bus,
- dev->source.subsys.u.usb.device);
+ dev->source.subsys.u.usb.device,
+ dev->source.subsys.u.usb.vendor,
+ dev->source.subsys.u.usb.product);
if (!usb)
goto done;
diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c
index 35b29ad..3c8b49a 100644
--- a/src/security/virt-aa-helper.c
+++ b/src/security/virt-aa-helper.c
@@ -836,24 +836,22 @@ get_files(vahControl * ctl)
virDomainHostdevDefPtr dev = ctl->def->hostdevs[i];
switch (dev->source.subsys.type) {
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB: {
- if (dev->source.subsys.u.usb.bus &&
- dev->source.subsys.u.usb.device) {
- usbDevice *usb = usbGetDevice(NULL,
- dev->source.subsys.u.usb.bus,
- dev->source.subsys.u.usb.device);
- if (usb == NULL)
- continue;
- rc = usbDeviceFileIterate(NULL, usb,
- file_iterate_cb, &buf);
- usbFreeDevice(NULL, usb);
- if (rc != 0)
- goto clean;
- else {
- /* TODO: deal with product/vendor better */
- rc = 0;
- }
- }
+ usbDevice *usb = usbGetDevice(NULL,
+ dev->source.subsys.u.usb.bus,
+ dev->source.subsys.u.usb.device,
+ dev->source.subsys.u.usb.vendor,
+ dev->source.subsys.u.usb.product);
+
+ if (usb == NULL)
+ continue;
+
+ rc = usbDeviceFileIterate(NULL, usb,
+ file_iterate_cb, &buf);
+ usbFreeDevice(NULL, usb);
+ if (rc != 0)
+ goto clean;
break;
+ }
}
/* TODO: update so files in /sys are readonly
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: {
diff --git a/src/util/hostusb.c b/src/util/hostusb.c
index 07e10b1..8fbb486 100644
--- a/src/util/hostusb.c
+++ b/src/util/hostusb.c
@@ -37,9 +37,10 @@
#include "util.h"
#include "virterror_internal.h"
+#define USB_SYSFS "/sys/bus/usb"
#define USB_DEVFS "/dev/bus/usb/"
-#define USB_ID_LEN 10 /* "XXXX XXXX" */
-#define USB_ADDR_LEN 8 /* "XXX:XXX" */
+#define USB_ID_LEN 10 /* "1234 5678" */
+#define USB_ADDR_LEN 8 /* "123:456" */
struct _usbDevice {
unsigned bus;
@@ -57,11 +58,108 @@ struct _usbDevice {
virReportErrorHelper(conn, VIR_FROM_NONE, code, __FILE__, \
__FUNCTION__, __LINE__, fmt)
+static int usbSysReadFile(virConnectPtr conn,
+ const char *f_name, const char *d_name,
+ int base, unsigned *value)
+{
+ int ret = -1, tmp;
+ char *buf = NULL;
+ char *filename = NULL;
+ char *ignore = NULL;
+
+ tmp = virAsprintf(&filename, USB_SYSFS "/devices/%s/%s", d_name, f_name);
+ if (tmp < 0) {
+ virReportOOMError(conn);
+ goto error;
+ }
+
+ if (virFileReadAll(filename, 1024, &buf) < 0)
+ goto error;
+
+ if (virStrToLong_ui(buf, &ignore, base, value) < 0) {
+ usbReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ _("Could not parse usb file %s"), filename);
+ goto error;
+ }
+
+ ret = 0;
+error:
+ VIR_FREE(filename);
+ VIR_FREE(buf);
+ return ret;
+}
+
+static int usbFindBusByVendor(virConnectPtr conn,
+ unsigned vendor, unsigned product,
+ unsigned *bus, unsigned *devno)
+{
+ DIR *dir = NULL;
+ int ret = -1, found = 0;
+ char *ignore = NULL;
+ struct dirent *de;
+
+ dir = opendir(USB_SYSFS "/devices");
+ if (!dir) {
+ virReportSystemError(conn, errno,
+ _("Could not open directory %s"),
+ USB_SYSFS "/devices");
+ goto error;
+ }
+
+ while ((de = readdir(dir))) {
+ unsigned found_prod, found_vend;
+ if (de->d_name[0] == '.' || strchr(de->d_name, ':'))
+ continue;
+
+ if (usbSysReadFile(conn, "idVendor", de->d_name,
+ 16, &found_vend) < 0)
+ goto error;
+ if (usbSysReadFile(conn, "idProduct", de->d_name,
+ 16, &found_prod) < 0)
+ goto error;
+
+ if (found_prod == product && found_vend == vendor) {
+ /* Lookup bus.addr info */
+ char *tmpstr = de->d_name;
+ unsigned found_bus, found_addr;
+
+ if (STREQ(de->d_name, "usb"))
+ tmpstr += 3;
+
+ if (virStrToLong_ui(tmpstr, &ignore, 10, &found_bus) < 0) {
+ usbReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ _("Failed to parse dir name '%s'"),
+ de->d_name);
+ goto error;
+ }
+
+ if (usbSysReadFile(conn, "devnum", de->d_name,
+ 10, &found_addr) < 0)
+ goto error;
+
+ *bus = found_bus;
+ *devno = found_addr;
+ found = 1;
+ break;
+ }
+ }
+
+ if (!found)
+ usbReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ _("Did not find USB device %x:%x"), vendor, product);
+ else
+ ret = 0;
+
+error:
+ return ret;
+}
usbDevice *
usbGetDevice(virConnectPtr conn,
unsigned bus,
- unsigned devno)
+ unsigned devno,
+ unsigned vendor,
+ unsigned product)
{
usbDevice *dev;
@@ -70,6 +168,12 @@ usbGetDevice(virConnectPtr conn,
return NULL;
}
+ if (vendor) {
+ /* Look up bus.dev by vendor:product */
+ if (usbFindBusByVendor(conn, vendor, product, &bus, &devno) < 0)
+ return NULL;
+ }
+
dev->bus = bus;
dev->dev = devno;
diff --git a/src/util/hostusb.h b/src/util/hostusb.h
index 7f75c8b..739a4aa 100644
--- a/src/util/hostusb.h
+++ b/src/util/hostusb.h
@@ -28,7 +28,9 @@ typedef struct _usbDevice usbDevice;
usbDevice *usbGetDevice (virConnectPtr conn,
unsigned bus,
- unsigned devno);
+ unsigned devno,
+ unsigned vendor,
+ unsigned product);
void usbFreeDevice (virConnectPtr conn,
usbDevice *dev);
--
1.6.5.2
14 years, 10 months
[libvirt] attach_device incompatibility between libvirt and qemu 0.12
by Gerhard Stenzel
Hi, I have a small libvirt-tck test script, in which I create a domain
without a NIC, then use attach_device to add a NIC. And then I do a ping
test to the domain. This stopped working after updating to latest fedora
and libvirt levels. After some hours, I now discovered that downgrading
to qemu 0.11 fixes it. So there seems to be some incompatibility with
qemu 0.12 and latest libvirt.
The expected output with qemu-system-x86-0.11.0-12.fc12.x86_64:
/usr/share/libvirt-tck/tests/scripts/network/100-ping-still-working.t ..
1..5
# Trying domain lookup by name
ok 1 - the running domain object
# Attaching the new interface d0:f:d0:f:2:1
ok 2 - interface has been attached
# xml contains mac address element (should be 1)
# 1
ok 3 - running domain has an ID > 0
# waiting for guests to boot
# PING 192.168.1.101 (192.168.1.101) 56(84) bytes of data.
# 64 bytes from 192.168.1.101: icmp_seq=1 ttl=64 time=2.17 ms
# 64 bytes from 192.168.1.101: icmp_seq=2 ttl=64 time=0.554 ms
# 64 bytes from 192.168.1.101: icmp_seq=3 ttl=64 time=0.510 ms
# 64 bytes from 192.168.1.101: icmp_seq=4 ttl=64 time=0.508 ms
# 64 bytes from 192.168.1.101: icmp_seq=5 ttl=64 time=0.505 ms
# 64 bytes from 192.168.1.101: icmp_seq=6 ttl=64 time=0.673 ms
# 64 bytes from 192.168.1.101: icmp_seq=7 ttl=64 time=0.528 ms
# 64 bytes from 192.168.1.101: icmp_seq=8 ttl=64 time=0.522 ms
# 64 bytes from 192.168.1.101: icmp_seq=9 ttl=64 time=0.506 ms
# 64 bytes from 192.168.1.101: icmp_seq=10 ttl=64 time=0.546 ms
#
# --- 192.168.1.101 ping statistics ---
# 10 packets transmitted, 10 received, 0% pacFor the working I see the
following lines in the log:
ket loss, time 9002ms
# rtt min/avg/max/mdev = 0.505/0.703/2.178/0.493 ms
ok 4 - ping 192.168.1.101 test
# cleaning up
# Detaching the 1st interface d0:f:d0:f:2:1
ok 5 - interface has been detached
ok
All tests successful.
Files=1, Tests=5, 20 wallclock secs ( 0.02 usr 0.01 sys + 0.22 cusr
0.15 csys = 0.40 CPU)
Result: PASS
The failing output with qemu-system-x86-0.11.0-12.fc12.x86_64:
/usr/share/libvirt-tck/tests/scripts/network/100-ping-still-working.t ..
1..5
# Trying domain lookup by name
ok 1 - the running domain object
# Attaching the new interface d0:f:d0:f:2:1
ok 2 - interface has been attached
# xml contains mac address element (should be 1)
# 1
ok 3 - running domain has an ID > 0
# waiting for guests to boot
# PING 192.168.1.101 (192.168.1.101) 56(84) bytes of data.
# From 192.168.1.1 icmp_seq=2 Destination Host Unreachable
# From 192.168.1.1 icmp_seq=3 Destination Host Unreachable
# From 192.168.1.1 icmp_seq=4 Destination Host Unreachable
# From 192.168.1.1 icmp_seq=6 Destination Host Unreachable
# From 192.168.1.1 icmp_seq=7 Destination Host Unreachable
# From 192.168.1.1 icmp_seq=8 Destination Host Unreachable
# From 192.168.1.1 icmp_seq=9 Destination Host Unreachable
# From 192.168.1.1 icmp_seq=10 Destination Host Unreachable
#
# --- 192.168.1.101 ping statistics ---
# 10 packets transmitted, 0 received, +8 errors, 100% packet loss, time
19000ms
# pipe 3
not ok 4 - ping 192.168.1.101 test
# Failed test 'ping 192.168.1.101 test'
#
at /usr/share/libvirt-tck/tests/scripts/network/100-ping-still-working.t
line 82.
# cleaning up
# Detaching the 1st interface d0:f:d0:f:2:1
ok 5 - interface has been detached
# Looks like you failed 1 test of 5.
Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/5 subtests
Test Summary Report
-------------------
/usr/share/libvirt-tck/tests/scripts/network/100-ping-still-working.t
(Wstat: 256 Tests: 5 Failed: 1)
Failed test: 4
Non-zero exit status: 1
Files=1, Tests=5, 30 wallclock secs ( 0.02 usr 0.02 sys + 0.24 cusr
0.13 csys = 0.41 CPU)
Result: FAIL
I see the following in the debug log:
...
qemuMonitorCommandWithHandler:216 : Send command 'getfd fd-tap.0' for
write with FD 18
...
For the working qemu:
qemuMonitorCommandWithHandler:221 : Receive command reply ret=0 errno=0
0 bytes '(null)'
For the failing qemu:
qemuMonitorCommandWithHandler:221 : Receive command reply ret=0 errno=0
44 bytes 'No file descriptor supplied via SCM_RIGHTS^M
'
Any ideas?
--
Best regards,
Gerhard Stenzel,
-----------------------------------------------------------------------------------------------------------------------------------
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
14 years, 10 months
[libvirt] [PATCH] events: Report errors on failure
by Cole Robinson
Signed-off-by: Cole Robinson <crobinso(a)redhat.com>
---
po/POTFILES.in | 1 +
src/conf/domain_event.c | 36 +++++++++++++++++++++++++++++-------
2 files changed, 30 insertions(+), 7 deletions(-)
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 1ab0859..c9c78b6 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -4,6 +4,7 @@ daemon/remote.c
daemon/stream.c
src/conf/cpu_conf.c
src/conf/domain_conf.c
+src/conf/domain_event.c
src/conf/interface_conf.c
src/conf/network_conf.c
src/conf/node_device_conf.c
diff --git a/src/conf/domain_event.c b/src/conf/domain_event.c
index 0fa2822..72f499c 100644
--- a/src/conf/domain_event.c
+++ b/src/conf/domain_event.c
@@ -26,6 +26,13 @@
#include "logging.h"
#include "datatypes.h"
#include "memory.h"
+#include "virterror_internal.h"
+
+#define VIR_FROM_THIS VIR_FROM_NONE
+
+#define eventReportError(conn, code, fmt...) \
+ virReportErrorHelper(conn, VIR_FROM_THIS, code, __FILE__, \
+ __FUNCTION__, __LINE__, fmt)
/**
@@ -87,6 +94,9 @@ virDomainEventCallbackListRemove(virConnectPtr conn,
return 0;
}
}
+
+ eventReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s",
+ _("could not find event callback for removal"));
return -1;
}
@@ -140,6 +150,9 @@ int virDomainEventCallbackListMarkDelete(virConnectPtr conn,
return 0;
}
}
+
+ eventReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s",
+ _("could not find event callback for deletion"));
return -1;
}
@@ -199,13 +212,14 @@ virDomainEventCallbackListAdd(virConnectPtr conn,
for (n=0; n < cbList->count; n++) {
if(cbList->callbacks[n]->cb == callback &&
conn == cbList->callbacks[n]->conn) {
- DEBUG0("WARNING: Callback already tracked");
+ eventReportError(conn, VIR_ERR_INTERNAL_ERROR, "%s",
+ _("event callback already tracked"));
return -1;
}
}
/* Allocate new event */
if (VIR_ALLOC(event) < 0) {
- DEBUG0("Error allocating event");
+ virReportOOMError(conn);
return -1;
}
event->conn = conn;
@@ -216,7 +230,7 @@ virDomainEventCallbackListAdd(virConnectPtr conn,
/* Make space on list */
n = cbList->count;
if (VIR_REALLOC_N(cbList->callbacks, n + 1) < 0) {
- DEBUG0("Error reallocating list");
+ virReportOOMError(conn);
VIR_FREE(event);
return -1;
}
@@ -242,8 +256,10 @@ virDomainEventQueuePtr virDomainEventQueueNew(void)
{
virDomainEventQueuePtr ret;
- if (VIR_ALLOC(ret) < 0)
+ if (VIR_ALLOC(ret) < 0) {
+ virReportOOMError(NULL);
return NULL;
+ }
return ret;
}
@@ -254,12 +270,15 @@ virDomainEventPtr virDomainEventNew(int id, const char *name,
{
virDomainEventPtr event;
- if (VIR_ALLOC(event) < 0)
+ if (VIR_ALLOC(event) < 0) {
+ virReportOOMError(NULL);
return NULL;
+ }
event->type = type;
event->detail = detail;
if (!(event->name = strdup(name))) {
+ virReportOOMError(NULL);
VIR_FREE(event);
return NULL;
}
@@ -318,8 +337,11 @@ virDomainEventQueuePop(virDomainEventQueuePtr evtQueue)
{
virDomainEventPtr ret;
- if(!evtQueue || evtQueue->count == 0 )
+ if (!evtQueue || evtQueue->count == 0 ) {
+ eventReportError(NULL, VIR_ERR_INTERNAL_ERROR, "%s",
+ _("event queue is empty, nothing to pop"));
return NULL;
+ }
ret = evtQueue->events[0];
@@ -357,7 +379,7 @@ virDomainEventQueuePush(virDomainEventQueuePtr evtQueue,
/* Make space on queue */
if (VIR_REALLOC_N(evtQueue->events,
evtQueue->count + 1) < 0) {
- DEBUG0("Error reallocating queue");
+ virReportOOMError(NULL);
return -1;
}
--
1.6.5.2
14 years, 10 months
[libvirt] [PATCH] daemon: Fix various error reporting issues
by Cole Robinson
Many node device calls weren't properly relaying error messages, and
domain event registeration was not checking for error.
Signed-off-by: Cole Robinson <crobinso(a)redhat.com>
---
daemon/remote.c | 38 +++++++++++++++++++++-----------------
1 files changed, 21 insertions(+), 17 deletions(-)
diff --git a/daemon/remote.c b/daemon/remote.c
index 0b30131..41b9974 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -231,7 +231,7 @@ remoteDispatchGetType (struct qemud_server *server ATTRIBUTE_UNUSED,
*/
ret->type = strdup (type);
if (!ret->type) {
- remoteDispatchFormatError (rerr, "%s", _("out of memory in strdup"));
+ remoteDispatchOOMError(rerr);
return -1;
}
@@ -4489,7 +4489,7 @@ remoteDispatchNodeDeviceDumpXml (struct qemud_server *server ATTRIBUTE_UNUSED,
dev = virNodeDeviceLookupByName(conn, args->name);
if (dev == NULL) {
- remoteDispatchFormatError(rerr, "%s", _("node_device not found"));
+ remoteDispatchConnError(rerr, conn);
return -1;
}
@@ -4520,7 +4520,7 @@ remoteDispatchNodeDeviceGetParent (struct qemud_server *server ATTRIBUTE_UNUSED,
dev = virNodeDeviceLookupByName(conn, args->name);
if (dev == NULL) {
- remoteDispatchFormatError(rerr, "%s", _("node_device not found"));
+ remoteDispatchConnError(rerr, conn);
return -1;
}
@@ -4562,7 +4562,7 @@ remoteDispatchNodeDeviceNumOfCaps (struct qemud_server *server ATTRIBUTE_UNUSED,
dev = virNodeDeviceLookupByName(conn, args->name);
if (dev == NULL) {
- remoteDispatchFormatError(rerr, "%s", _("node_device not found"));
+ remoteDispatchConnError(rerr, conn);
return -1;
}
@@ -4591,7 +4591,7 @@ remoteDispatchNodeDeviceListCaps (struct qemud_server *server ATTRIBUTE_UNUSED,
dev = virNodeDeviceLookupByName(conn, args->name);
if (dev == NULL) {
- remoteDispatchFormatError(rerr, "%s", _("node_device not found"));
+ remoteDispatchConnError(rerr, conn);
return -1;
}
@@ -4634,7 +4634,7 @@ remoteDispatchNodeDeviceDettach (struct qemud_server *server ATTRIBUTE_UNUSED,
dev = virNodeDeviceLookupByName(conn, args->name);
if (dev == NULL) {
- remoteDispatchFormatError(rerr, "%s", _("node_device not found"));
+ remoteDispatchConnError(rerr, conn);
return -1;
}
@@ -4661,7 +4661,7 @@ remoteDispatchNodeDeviceReAttach (struct qemud_server *server ATTRIBUTE_UNUSED,
dev = virNodeDeviceLookupByName(conn, args->name);
if (dev == NULL) {
- remoteDispatchFormatError(rerr, "%s", _("node_device not found"));
+ remoteDispatchConnError(rerr, conn);
return -1;
}
@@ -4688,7 +4688,7 @@ remoteDispatchNodeDeviceReset (struct qemud_server *server ATTRIBUTE_UNUSED,
dev = virNodeDeviceLookupByName(conn, args->name);
if (dev == NULL) {
- remoteDispatchFormatError(rerr, "%s", _("node_device not found"));
+ remoteDispatchConnError(rerr, conn);
return -1;
}
@@ -4738,7 +4738,7 @@ remoteDispatchNodeDeviceDestroy(struct qemud_server *server ATTRIBUTE_UNUSED,
dev = virNodeDeviceLookupByName(conn, args->name);
if (dev == NULL) {
- remoteDispatchFormatError(rerr, "%s", _("node_device not found"));
+ remoteDispatchConnError(rerr, conn);
return -1;
}
@@ -4766,11 +4766,14 @@ remoteDispatchDomainEventsRegister (struct qemud_server *server ATTRIBUTE_UNUSED
{
CHECK_CONN(client);
- /* Register event delivery callback */
- REMOTE_DEBUG("%s","Registering to relay remote events");
- virConnectDomainEventRegister(conn, remoteRelayDomainEvent, client, NULL);
+ if (virConnectDomainEventRegister(conn,
+ remoteRelayDomainEvent,
+ client, NULL) < 0) {
+ remoteDispatchConnError(rerr, conn);
+ return -1;
+ }
- if(ret)
+ if (ret)
ret->cb_registered = 1;
return 0;
}
@@ -4786,11 +4789,12 @@ remoteDispatchDomainEventsDeregister (struct qemud_server *server ATTRIBUTE_UNUS
{
CHECK_CONN(client);
- /* Deregister event delivery callback */
- REMOTE_DEBUG("%s","Deregistering to relay remote events");
- virConnectDomainEventDeregister(conn, remoteRelayDomainEvent);
+ if (virConnectDomainEventDeregister(conn, remoteRelayDomainEvent) < 0) {
+ remoteDispatchConnError(rerr, conn);
+ return -1;
+ }
- if(ret)
+ if (ret)
ret->cb_registered = 0;
return 0;
}
--
1.6.5.2
14 years, 10 months
[libvirt] [PATCH] daemon: Don't blindly unregister domain events
by Cole Robinson
The daemon will attempt to unregister domain events on client disconnect,
even if no events were ever registered. This raises an unneeded error.
Track in the qemu_client structure if events have been registered, and
check this when performing cleanup.
Signed-off-by: Cole Robinson <crobinso(a)redhat.com>
---
daemon/libvirtd.c | 2 +-
daemon/libvirtd.h | 1 +
daemon/remote.c | 4 ++++
3 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index c53ef0a..61a9728 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -1447,7 +1447,7 @@ void qemudDispatchClientFailure(struct qemud_client *client) {
}
/* Deregister event delivery callback */
- if(client->conn) {
+ if (client->conn && client->domain_events_registered) {
DEBUG0("Deregistering to relay remote events");
virConnectDomainEventDeregister(client->conn, remoteRelayDomainEvent);
}
diff --git a/daemon/libvirtd.h b/daemon/libvirtd.h
index e3624c6..2f647f3 100644
--- a/daemon/libvirtd.h
+++ b/daemon/libvirtd.h
@@ -177,6 +177,7 @@ struct qemud_client {
int watch;
int readonly:1;
int closing:1;
+ int domain_events_registered:1;
struct sockaddr_storage addr;
socklen_t addrlen;
diff --git a/daemon/remote.c b/daemon/remote.c
index 41b9974..e39d6d1 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -4775,6 +4775,8 @@ remoteDispatchDomainEventsRegister (struct qemud_server *server ATTRIBUTE_UNUSED
if (ret)
ret->cb_registered = 1;
+
+ client->domain_events_registered = 1;
return 0;
}
@@ -4796,6 +4798,8 @@ remoteDispatchDomainEventsDeregister (struct qemud_server *server ATTRIBUTE_UNUS
if (ret)
ret->cb_registered = 0;
+
+ client->domain_events_registered = 0;
return 0;
}
--
1.6.5.2
14 years, 10 months
[libvirt] [PATCH] qemu: Check for ia64 kvm
by Cole Robinson
From: Dustin Xiong <x_k_123(a)hotmail.com>
Ported to current code. Untested, but builds fine.
Signed-off-by: Cole Robinson <crobinso(a)redhat.com>
---
src/qemu/qemu_conf.c | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index d3da776..0d970d6 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -373,12 +373,19 @@ static const struct qemu_feature_flags const arch_info_x86_64_flags [] = {
{ "apic", 1, 0 },
};
+static const struct qemu_feature_flags const arch_info_ia64_flags [] = {
+ { "acpi", 1, 1 },
+ { "apic", 1, 0 },
+};
+
/* The archicture tables for supported QEMU archs */
static const struct qemu_arch_info const arch_info_hvm[] = {
{ "i686", 32, NULL, "/usr/bin/qemu",
"/usr/bin/qemu-system-x86_64", arch_info_i686_flags, 4 },
{ "x86_64", 64, NULL, "/usr/bin/qemu-system-x86_64",
NULL, arch_info_x86_64_flags, 2 },
+ { "itanium", 64, NULL, "/usr/bin/qemu-system-ia64",
+ NULL, arch_info_ia64_flags, 2},
{ "arm", 32, NULL, "/usr/bin/qemu-system-arm", NULL, NULL, 0 },
{ "mips", 32, NULL, "/usr/bin/qemu-system-mips", NULL, NULL, 0 },
{ "mipsel", 32, NULL, "/usr/bin/qemu-system-mipsel", NULL, NULL, 0 },
--
1.6.5.2
14 years, 10 months