[libvirt] [PATCH 0/12] Improve security driver handling & QEMU DAC management
by Daniel P. Berrange
This patch series does some work on te security drivers, and the QEMU code
for managing DAC permissions on files.
The core goal is to turn the QEMU driver DAC file management code into a
security driver. Instead of QEMU calling into the SELinux/AppArmour drivers
directly, a stacked driver module is introduced. This delegates all operations
to first the QEMU DAC driver, and then the main SELinux/AppArmour driver.
The end result is that all the permissions management code is removed from
the QEMU driver, and we're left with just simple security driver calls.
In the process of this a number of flaws in the current hotplug code were
found, and code was generally tidied up with a view to making it easier to
manage.
Finally, we add the ability to turn off the QEMU DAC file managment code,
and also deal gracefully with failures to change ownership (eg on NFS with
root squash, or readonly FS).
14 years, 9 months
[libvirt] [PATCH] util: Remove logging handlers in virExec
by Cole Robinson
This allows debug statements and raised errors in hook functions to
actually be logged somewhere (stderr). Users can enable debugging in the
daemon and now see more info in /var/log/libvirt/...
Signed-off-by: Cole Robinson <crobinso(a)redhat.com>
---
src/util/util.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/src/util/util.c b/src/util/util.c
index 44a4b2f..23d781d 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -334,6 +334,7 @@ __virExec(virConnectPtr conn,
int pipeerr[2] = {-1,-1};
int childout = -1;
int childerr = -1;
+ int logprio;
sigset_t oldmask, newmask;
struct sigaction sig_action;
@@ -452,6 +453,11 @@ __virExec(virConnectPtr conn,
of being seen / logged */
virSetErrorFunc(NULL, NULL);
+ /* Make sure any hook logging is sent to stderr */
+ logprio = virLogGetDefaultPriority();
+ virLogReset();
+ virLogSetDefaultPriority(logprio);
+
/* Clear out all signal handlers from parent so nothing
unexpected can happen in our child once we unblock
signals */
--
1.6.5.2
14 years, 9 months
[libvirt] [PATCH] xen_hypervisor.c: avoid NULL deref for NULL domain argument
by Jim Meyering
When "domain" is NULL, don't deref NULL. Instead, just return -1,
as in many other functions in this file, and as this function did
up until a month ago.
An alternative (taken 3 times in this file) is to do this:
virXenErrorFunc (NULL, VIR_ERR_INTERNAL_ERROR, __FUNCTION__,
"domain or conn is NULL", 0);
return -1;
I could go either way.
>From 177556167775b806a29bcb1af7ba4294d1909912 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Tue, 26 Jan 2010 20:17:07 +0100
Subject: [PATCH] xen_hypervisor.c: avoid NULL deref for NULL domain argument
* src/xen/xen_hypervisor.c (xenHypervisorGetVcpus): Don't attempt
to diagnose an unlikely NULL-domain or NULL-domain->conn error.
---
src/xen/xen_hypervisor.c | 7 ++-----
1 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/src/xen/xen_hypervisor.c b/src/xen/xen_hypervisor.c
index 6d8accc..0257be2 100644
--- a/src/xen/xen_hypervisor.c
+++ b/src/xen/xen_hypervisor.c
@@ -1,7 +1,7 @@
/*
* xen_internal.c: direct access to Xen hypervisor level
*
- * Copyright (C) 2005, 2006, 2007, 2008, 2009 Red Hat, Inc.
+ * Copyright (C) 2005-2010 Red Hat, Inc.
*
* See COPYING.LIB for the License of this software
*
@@ -3475,11 +3475,8 @@ xenHypervisorGetVcpus(virDomainPtr domain, virVcpuInfoPtr info, int maxinfo,
virVcpuInfoPtr ipt;
int nbinfo, i;
- if (domain == NULL || domain->conn == NULL) {
- virXenErrorFunc (domain->conn, VIR_ERR_INVALID_ARG, __FUNCTION__,
- "invalid argument", 0);
+ if (domain == NULL || domain->conn == NULL)
return -1;
- }
priv = (xenUnifiedPrivatePtr) domain->conn->privateData;
if (priv->handle < 0 || (domain->id < 0) ||
--
1.7.0.rc0.140.gfbe7
14 years, 9 months
[libvirt] libvirt: python bindings
by Sharadha Prabhakar (3P)
Hi,
I'm writing XenServer APIs for libvirt and trying to test it on virt-Manager.
I need to build the libvirt python bindings for that.
I tried this for libvirt.
./configure -with-xenapi -with-python
make
make install
I suppose this is supposed to build a .libs directory with libvirtmod.so in the ~/libvirt/python/
But I don't seem to have this at all after build. It was a clean build with no errors.
I need libvirtmod.so to link with virt-manager. I'm using libvirt version 0.7.4
Can anyone help me with this. Am I missing something here
Thanks in Advance,
-SP
14 years, 9 months
[libvirt] virt-manager network properties
by C.J. Adams-Collier
Hey Dan, list,
It seems to me that virt-manager could do with more information about
the virtual network devices, the DHCP leases on them, maybe a view of
the arp table, etc.
To this end, I've abused Dan's .glade file a bit and put some stub code
in virtManger/host.py
Could I get some comments and some recommendations for next steps? It's
been a while since I've done any glade'ing...
Cheers,
C.J.
14 years, 9 months
[libvirt] [PATCH] qemu_monitor_json.c: avoid many unconditional leaks
by Jim Meyering
Actually, the preceding patch fixed only the one leak that had been
introduced in the last month or so. Looking at the many other functions
that do the same sort of thing (call qemuMonitorJSONMakeCommand, and
later virJSONValueFree), I saw that they all had exactly the same leak.
So this amended patch fixes all of them:
>From 28f820354dcae9950cad042ea78a893fd9475830 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Wed, 27 Jan 2010 09:58:12 +0100
Subject: [PATCH] qemu_monitor_json.c: avoid many unconditional leaks
* src/qemu/qemu_monitor_json.c (qemuMonitorJSONAttachDrive):
Don't leak the buffer behind a virJSONValuePtr.
(qemuMonitorJSONStartCPUs): Likewise.
(qemuMonitorJSONStopCPUs, qemuMonitorJSONSystemPowerdown): Likewise.
(qemuMonitorJSONGetCPUInfo, qemuMonitorJSONGetBalloonInfo): Likewise.
(qemuMonitorJSONGetBlockStatsInfo): Likewise.
(qemuMonitorJSONSetVNCPassword): Likewise.
(qemuMonitorJSONSetBalloon, qemuMonitorJSONEjectMedia): Likewise.
(qemuMonitorJSONChangeMedia, qemuMonitorJSONSaveMemory): Likewise.
(qemuMonitorJSONSetMigrationSpeed): Likewise.
(qemuMonitorJSONGetMigrationStatus, qemuMonitorJSONMigrate): Likewise.
(qemuMonitorJSONMigrateCancel, qemuMonitorJSONAddUSB): Likewise.
(qemuMonitorJSONAddPCIHostDevice, qemuMonitorJSONAddPCIDisk): Likewise.
(qemuMonitorJSONAddPCINetwork, qemuMonitorJSONRemovePCIDevice): Likewise.
(qemuMonitorJSONSendFileHandle): Likewise.
(qemuMonitorJSONCloseFileHandle): Likewise.
(qemuMonitorJSONAddHostNetwork): Likewise.
(qemuMonitorJSONRemoveHostNetwork): Likewise.
(qemuMonitorJSONGetPtyPaths): Likewise.
(qemuMonitorJSONAttachPCIDiskController): Likewise.
---
src/qemu/qemu_monitor_json.c | 27 +++++++++++++++++++++++++++
1 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 8e88c7e..b6c3449 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -492,6 +492,7 @@ qemuMonitorJSONStartCPUs(qemuMonitorPtr mon,
ret = qemuMonitorJSONCheckError(cmd, reply);
virJSONValueFree(cmd);
+ VIR_FREE(cmd);
virJSONValueFree(reply);
return ret;
}
@@ -512,6 +513,7 @@ qemuMonitorJSONStopCPUs(qemuMonitorPtr mon)
ret = qemuMonitorJSONCheckError(cmd, reply);
virJSONValueFree(cmd);
+ VIR_FREE(cmd);
virJSONValueFree(reply);
return ret;
}
@@ -531,6 +533,7 @@ int qemuMonitorJSONSystemPowerdown(qemuMonitorPtr mon)
ret = qemuMonitorJSONCheckError(cmd, reply);
virJSONValueFree(cmd);
+ VIR_FREE(cmd);
virJSONValueFree(reply);
return ret;
}
@@ -637,6 +640,7 @@ int qemuMonitorJSONGetCPUInfo(qemuMonitorPtr mon,
ret = qemuMonitorJSONExtractCPUInfo(reply, pids);
virJSONValueFree(cmd);
+ VIR_FREE(cmd);
virJSONValueFree(reply);
return ret;
}
@@ -696,6 +700,7 @@ int qemuMonitorJSONGetBalloonInfo(qemuMonitorPtr mon,
cleanup:
virJSONValueFree(cmd);
+ VIR_FREE(cmd);
virJSONValueFree(reply);
return ret;
}
@@ -800,6 +805,7 @@ int qemuMonitorJSONGetBlockStatsInfo(qemuMonitorPtr mon,
cleanup:
virJSONValueFree(cmd);
+ VIR_FREE(cmd);
virJSONValueFree(reply);
return ret;
}
@@ -824,6 +830,7 @@ int qemuMonitorJSONSetVNCPassword(qemuMonitorPtr mon,
ret = qemuMonitorJSONCheckError(cmd, reply);
virJSONValueFree(cmd);
+ VIR_FREE(cmd);
virJSONValueFree(reply);
return ret;
}
@@ -861,6 +868,7 @@ int qemuMonitorJSONSetBalloon(qemuMonitorPtr mon,
cleanup:
virJSONValueFree(cmd);
+ VIR_FREE(cmd);
virJSONValueFree(reply);
return ret;
}
@@ -884,6 +892,7 @@ int qemuMonitorJSONEjectMedia(qemuMonitorPtr mon,
ret = qemuMonitorJSONCheckError(cmd, reply);
virJSONValueFree(cmd);
+ VIR_FREE(cmd);
virJSONValueFree(reply);
return ret;
}
@@ -918,6 +927,7 @@ int qemuMonitorJSONChangeMedia(qemuMonitorPtr mon,
ret = qemuMonitorJSONCheckError(cmd, reply);
virJSONValueFree(cmd);
+ VIR_FREE(cmd);
virJSONValueFree(reply);
return ret;
}
@@ -945,6 +955,7 @@ static int qemuMonitorJSONSaveMemory(qemuMonitorPtr mon,
ret = qemuMonitorJSONCheckError(cmd, reply);
virJSONValueFree(cmd);
+ VIR_FREE(cmd);
virJSONValueFree(reply);
return ret;
}
@@ -991,6 +1002,7 @@ int qemuMonitorJSONSetMigrationSpeed(qemuMonitorPtr mon,
ret = qemuMonitorJSONCheckError(cmd, reply);
virJSONValueFree(cmd);
+ VIR_FREE(cmd);
virJSONValueFree(reply);
return ret;
}
@@ -1084,6 +1096,7 @@ int qemuMonitorJSONGetMigrationStatus(qemuMonitorPtr mon,
ret = -1;
virJSONValueFree(cmd);
+ VIR_FREE(cmd);
virJSONValueFree(reply);
return ret;
}
@@ -1109,6 +1122,7 @@ static int qemuMonitorJSONMigrate(qemuMonitorPtr mon,
ret = qemuMonitorJSONCheckError(cmd, reply);
virJSONValueFree(cmd);
+ VIR_FREE(cmd);
virJSONValueFree(reply);
return ret;
}
@@ -1206,6 +1220,7 @@ int qemuMonitorJSONMigrateCancel(qemuMonitorPtr mon)
ret = qemuMonitorJSONCheckError(cmd, reply);
virJSONValueFree(cmd);
+ VIR_FREE(cmd);
virJSONValueFree(reply);
return ret;
}
@@ -1229,6 +1244,7 @@ static int qemuMonitorJSONAddUSB(qemuMonitorPtr mon,
ret = qemuMonitorJSONCheckError(cmd, reply);
virJSONValueFree(cmd);
+ VIR_FREE(cmd);
virJSONValueFree(reply);
return ret;
}
@@ -1369,6 +1385,7 @@ int qemuMonitorJSONAddPCIHostDevice(qemuMonitorPtr mon,
ret = -1;
virJSONValueFree(cmd);
+ VIR_FREE(cmd);
virJSONValueFree(reply);
return ret;
}
@@ -1410,6 +1427,7 @@ int qemuMonitorJSONAddPCIDisk(qemuMonitorPtr mon,
ret = -1;
virJSONValueFree(cmd);
+ VIR_FREE(cmd);
virJSONValueFree(reply);
return ret;
}
@@ -1442,6 +1460,7 @@ int qemuMonitorJSONAddPCINetwork(qemuMonitorPtr mon,
ret = -1;
virJSONValueFree(cmd);
+ VIR_FREE(cmd);
virJSONValueFree(reply);
return ret;
}
@@ -1475,6 +1494,7 @@ int qemuMonitorJSONRemovePCIDevice(qemuMonitorPtr mon,
ret = qemuMonitorJSONCheckError(cmd, reply);
virJSONValueFree(cmd);
+ VIR_FREE(cmd);
virJSONValueFree(reply);
return ret;
}
@@ -1498,6 +1518,7 @@ int qemuMonitorJSONSendFileHandle(qemuMonitorPtr mon,
ret = qemuMonitorJSONCheckError(cmd, reply);
virJSONValueFree(cmd);
+ VIR_FREE(cmd);
virJSONValueFree(reply);
return ret;
}
@@ -1520,6 +1541,7 @@ int qemuMonitorJSONCloseFileHandle(qemuMonitorPtr mon,
ret = qemuMonitorJSONCheckError(cmd, reply);
virJSONValueFree(cmd);
+ VIR_FREE(cmd);
virJSONValueFree(reply);
return ret;
}
@@ -1542,6 +1564,7 @@ int qemuMonitorJSONAddHostNetwork(qemuMonitorPtr mon,
ret = qemuMonitorJSONCheckError(cmd, reply);
virJSONValueFree(cmd);
+ VIR_FREE(cmd);
virJSONValueFree(reply);
return ret;
}
@@ -1566,6 +1589,7 @@ int qemuMonitorJSONRemoveHostNetwork(qemuMonitorPtr mon,
ret = qemuMonitorJSONCheckError(cmd, reply);
virJSONValueFree(cmd);
+ VIR_FREE(cmd);
virJSONValueFree(reply);
return ret;
}
@@ -1665,6 +1689,7 @@ int qemuMonitorJSONGetPtyPaths(qemuMonitorPtr mon,
ret = qemuMonitorJSONExtractPtyPaths(reply, paths);
virJSONValueFree(cmd);
+ VIR_FREE(cmd);
virJSONValueFree(reply);
return ret;
}
@@ -1705,6 +1730,7 @@ int qemuMonitorJSONAttachPCIDiskController(qemuMonitorPtr mon,
ret = -1;
virJSONValueFree(cmd);
+ VIR_FREE(cmd);
virJSONValueFree(reply);
return ret;
}
@@ -1773,6 +1799,7 @@ int qemuMonitorJSONAttachDrive(qemuMonitorPtr mon,
ret = -1;
virJSONValueFree(cmd);
+ VIR_FREE(cmd);
virJSONValueFree(reply);
return ret;
}
--
1.7.0.rc0.140.gfbe7
14 years, 9 months
[libvirt] [PATCH] cpu_x86.c: avoid NULL-deref for invalid arguments
by Jim Meyering
Passing a NULL "models" pointer along with a
contradictory "nmodels >= 1" would cause a NULL-dereference.
An alternative to the fix below would be simply to guard
the NULL-derferencing strcmp with "if (models ...",
but that wouldn't tell the caller that they're passing
bogus arguments.
>From f57bd1fbe7a41b1b9d8ba1be61790e95b5060ddc Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Tue, 26 Jan 2010 19:58:48 +0100
Subject: [PATCH] cpu_x86.c: avoid NULL-deref for invalid arguments
* src/cpu/cpu_x86.c (x86Decode): Do not dereference NULL
when "models" is NULL and nmodels is 1 or greater.
---
src/cpu/cpu_x86.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index dae7c90..47dc400 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -1,7 +1,7 @@
/*
* cpu_x86.c: CPU driver for CPUs with x86 compatible CPUID instruction
*
- * 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
@@ -954,6 +954,9 @@ x86Decode(virCPUDefPtr cpu,
if (data == NULL || (map = x86LoadMap()) == NULL)
return -1;
+ if (models == NULL && nmodels != 0)
+ return -1;
+
candidate = map->models;
while (candidate != NULL) {
bool allowed = (models == NULL);
--
1.7.0.rc0.140.gfbe7
14 years, 9 months
[libvirt] [PATCH] maint: avoid excess parens in STREQ
by Eric Blake
* src/internal.h (STREQ, STRCASEEQ, STRNEQ, STRCASENEQ, STREQLEN)
(STRCASEEQLEN, STRNEQLEN, STRCASENEQLEN, STRPREFIX): Avoid
redundant parenthesis.
* examples/domain-events/events-c/event-test.c (STREQ): Likewise.
* src/storage/parthelper.c (STREQ): Likewise.
---
These macros were originally inspired by Jim Meyering, who has since made
this same cleanup elsewhere. For example:
http://lists.gnu.org/archive/html/bug-gnulib/2010-01/msg00293.html
examples/domain-events/events-c/event-test.c | 2 +-
src/internal.h | 18 +++++++++---------
src/storage/parthelper.c | 4 ++--
3 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/examples/domain-events/events-c/event-test.c b/examples/domain-events/events-c/event-test.c
index b2eb1d5..e8f5505 100644
--- a/examples/domain-events/events-c/event-test.c
+++ b/examples/domain-events/events-c/event-test.c
@@ -14,7 +14,7 @@
__func__, __LINE__)
#define DEBUG(fmt, ...) printf("%s:%d: " fmt "\n", \
__func__, __LINE__, __VA_ARGS__)
-#define STREQ(a,b) (strcmp((a),(b)) == 0)
+#define STREQ(a,b) (strcmp(a,b) == 0)
#ifndef ATTRIBUTE_UNUSED
#define ATTRIBUTE_UNUSED __attribute__((__unused__))
diff --git a/src/internal.h b/src/internal.h
index 5ca1fa3..ec8a49f 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -48,15 +48,15 @@
#define N_(str) dgettext(GETTEXT_PACKAGE, (str))
/* String equality tests, suggested by Jim Meyering. */
-#define STREQ(a,b) (strcmp((a),(b)) == 0)
-#define STRCASEEQ(a,b) (strcasecmp((a),(b)) == 0)
-#define STRNEQ(a,b) (strcmp((a),(b)) != 0)
-#define STRCASENEQ(a,b) (strcasecmp((a),(b)) != 0)
-#define STREQLEN(a,b,n) (strncmp((a),(b),(n)) == 0)
-#define STRCASEEQLEN(a,b,n) (strncasecmp((a),(b),(n)) == 0)
-#define STRNEQLEN(a,b,n) (strncmp((a),(b),(n)) != 0)
-#define STRCASENEQLEN(a,b,n) (strncasecmp((a),(b),(n)) != 0)
-#define STRPREFIX(a,b) (strncmp((a),(b),strlen((b))) == 0)
+#define STREQ(a,b) (strcmp(a,b) == 0)
+#define STRCASEEQ(a,b) (strcasecmp(a,b) == 0)
+#define STRNEQ(a,b) (strcmp(a,b) != 0)
+#define STRCASENEQ(a,b) (strcasecmp(a,b) != 0)
+#define STREQLEN(a,b,n) (strncmp(a,b,n) == 0)
+#define STRCASEEQLEN(a,b,n) (strncasecmp(a,b,n) == 0)
+#define STRNEQLEN(a,b,n) (strncmp(a,b,n) != 0)
+#define STRCASENEQLEN(a,b,n) (strncasecmp(a,b,n) != 0)
+#define STRPREFIX(a,b) (strncmp(a,b,strlen(b)) == 0)
#define NUL_TERMINATE(buf) do { (buf)[sizeof(buf)-1] = '\0'; } while (0)
#define ARRAY_CARDINALITY(Array) (sizeof (Array) / sizeof *(Array))
diff --git a/src/storage/parthelper.c b/src/storage/parthelper.c
index ab04842..5626cd2 100644
--- a/src/storage/parthelper.c
+++ b/src/storage/parthelper.c
@@ -10,7 +10,7 @@
* in a reliable fashion if merely after a list of partitions & sizes,
* though it is fine for creating partitions.
*
- * Copyright (C) 2007-2008 Red Hat, Inc.
+ * Copyright (C) 2007-2008, 2010 Red Hat, Inc.
* Copyright (C) 2007-2008 Daniel P. Berrange
*
* This library is free software; you can redistribute it and/or
@@ -37,7 +37,7 @@
#include <string.h>
/* we don't need to include the full internal.h just for this */
-#define STREQ(a,b) (strcmp((a),(b)) == 0)
+#define STREQ(a,b) (strcmp(a,b) == 0)
/* Make the comparisons below fail if your parted headers
are so old that they lack the definition. */
--
1.6.6
14 years, 9 months
[libvirt] [PATCH] Log flags in virConnectCompareCPU
by Jiri Denemark
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
src/libvirt.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/libvirt.c b/src/libvirt.c
index 32f9fc4..8a9ee20 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -10951,7 +10951,7 @@ virConnectCompareCPU(virConnectPtr conn,
const char *xmlDesc,
unsigned int flags)
{
- VIR_DEBUG("conn=%p, xmlDesc=%s", conn, xmlDesc);
+ VIR_DEBUG("conn=%p, xmlDesc=%s, flags=%u", conn, xmlDesc, flags);
virResetLastError();
--
1.6.6.1
14 years, 9 months
[libvirt] [PATCH] Fix PCI host reattach on domain detach.
by Chris Lalancette
Similar to the race fixed by
be34c3c7efbb1ea8999530f98b99c5dde3793f84, make sure
to wait around for KVM to release the resources from
a hot-detached PCI device before attempting to
rebind that device to the host driver.
Signed-off-by: Chris Lalancette <clalance(a)redhat.com>
---
src/qemu/qemu_driver.c | 39 +++++++++++++++++++++++----------------
1 files changed, 23 insertions(+), 16 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index bbdbe33..5bf6743 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -2240,6 +2240,26 @@ cleanup:
}
static void
+qemudReattachManagedDevice(pciDevice *dev)
+{
+ int retries = 100;
+
+ if (pciDeviceGetManaged(dev)) {
+ while (pciWaitForDeviceCleanup(dev, "kvm_assigned_device")
+ && retries) {
+ usleep(100*1000);
+ retries--;
+ }
+ if (pciReAttachDevice(NULL, dev) < 0) {
+ virErrorPtr err = virGetLastError();
+ VIR_ERROR(_("Failed to re-attach PCI device: %s"),
+ err ? err->message : "");
+ virResetError(err);
+ }
+ }
+}
+
+static void
qemuDomainReAttachHostDevices(virConnectPtr conn,
struct qemud_driver *driver,
virDomainDefPtr def)
@@ -2279,20 +2299,7 @@ qemuDomainReAttachHostDevices(virConnectPtr conn,
for (i = 0; i < pciDeviceListCount(pcidevs); i++) {
pciDevice *dev = pciDeviceListGet(pcidevs, i);
- int retries = 100;
- if (pciDeviceGetManaged(dev)) {
- while (pciWaitForDeviceCleanup(dev, "kvm_assigned_device")
- && retries) {
- usleep(100*1000);
- retries--;
- }
- if (pciReAttachDevice(NULL, dev) < 0) {
- virErrorPtr err = virGetLastError();
- VIR_ERROR(_("Failed to re-attach PCI device: %s"),
- err ? err->message : "");
- virResetError(err);
- }
- }
+ qemudReattachManagedDevice(dev);
}
pciDeviceListFree(conn, pcidevs);
@@ -6128,11 +6135,11 @@ static int qemudDomainDetachHostPciDevice(virConnectPtr conn,
if (!pci)
ret = -1;
else {
+ pciDeviceSetManaged(pci, detach->managed);
pciDeviceListDel(conn, driver->activePciHostdevs, pci);
if (pciResetDevice(conn, pci, driver->activePciHostdevs) < 0)
ret = -1;
- if (detach->managed && pciReAttachDevice(conn, pci) < 0)
- ret = -1;
+ qemudReattachManagedDevice(pci);
pciFreeDevice(conn, pci);
}
--
1.6.6
14 years, 9 months