[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, 10 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, 10 months
[libvirt] [PATCH] Look in /usr/libexec for the qemu-kvm binary.
by Chris Lalancette
On RHEL-5 the qemu-kvm binary is located in /usr/libexec.
To reduce confusion for people trying to run upstream libvirt
on RHEL-5 machines, make the qemu driver look in /usr/libexec
for the qemu-kvm binary.
To make this work, I modified virFindFileInPath to handle an
absolute path correctly. I also ran into an issue where
NULL was sometimes being passed for the file parameter
to virFindFileInPath; it didn't crash prior to this patch
since it was building paths like /usr/bin/(null). This
is non-standard behavior, though, so I added a NULL
check at the beginning.
Signed-off-by: Chris Lalancette <clalance(a)redhat.com>
---
src/qemu/qemu_conf.c | 3 ++-
src/util/util.c | 13 +++++++++++++
2 files changed, 15 insertions(+), 1 deletions(-)
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index f4a6c08..d5e38c2 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -804,7 +804,8 @@ qemudCapsInitGuest(virCapsPtr caps,
if (STREQ(info->arch, hostmachine) ||
(STREQ(hostmachine, "x86_64") && STREQ(info->arch, "i686"))) {
if (access("/dev/kvm", F_OK) == 0) {
- const char *const kvmbins[] = { "qemu-kvm", /* Fedora */
+ const char *const kvmbins[] = { "/usr/libexec/qemu-kvm", /* RHEL */
+ "qemu-kvm", /* Fedora */
"kvm" }; /* Upstream .spec */
for (i = 0; i < ARRAY_CARDINALITY(kvmbins); ++i) {
diff --git a/src/util/util.c b/src/util/util.c
index 0ce5026..394ef35 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -1114,6 +1114,19 @@ char *virFindFileInPath(const char *file)
char *pathseg;
char fullpath[PATH_MAX];
+ if (file == NULL)
+ return NULL;
+
+ /* if we are passed an absolute path (starting with /), return a
+ * copy of that path
+ */
+ if (file[0] == '/') {
+ if (virFileExists(file))
+ return strdup(file);
+ else
+ return NULL;
+ }
+
/* copy PATH env so we can tweak it */
if (virStrcpyStatic(pathenv, getenv("PATH")) == NULL)
return NULL;
--
1.6.6
14 years, 10 months
[libvirt] [PATCH] Clarify lack of generated IDE -device string in QEMU driver
by Matthew Booth
The QEMU driver contained code to generate a -device string for piix4-ide, but
wasn't using it. This was intentional. This change removes the string generation
and adds a comment explaining why no -device is necessary.
* src/qemu/qemu_conf.c: Remove VIR_DOMAIN_CONTROLLER_TYPE_IDE handler in
qemuBuildControllerDevStr(). Add comments.
---
src/qemu/qemu_conf.c | 16 ++++++++--------
1 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index f4a6c08..1c4f326 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -2121,11 +2121,8 @@ qemuBuildControllerDevStr(virDomainControllerDefPtr def)
virBufferVSprintf(&buf, ",id=scsi%d", def->idx);
break;
+ /* We always get an IDE controller, whether we want it or not. */
case VIR_DOMAIN_CONTROLLER_TYPE_IDE:
- virBufferAddLit(&buf, "piix4-ide");
- virBufferVSprintf(&buf, ",id=ide%d", def->idx);
- break;
-
default:
goto error;
}
@@ -3141,16 +3138,19 @@ int qemudBuildCommandLine(virConnectPtr conn,
if (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE) {
for (i = 0 ; i < def->ncontrollers ; i++) {
- char *scsi;
- if (def->controllers[i]->type != VIR_DOMAIN_CONTROLLER_TYPE_SCSI)
+ /* We don't add an explicit IDE controller because the provided
+ * PIIX4 device already includes one. It isn't possible to remove
+ * the PIIX4. */
+ if (def->controllers[i]->type == VIR_DOMAIN_CONTROLLER_TYPE_IDE)
continue;
ADD_ARG_LIT("-device");
- if (!(scsi = qemuBuildControllerDevStr(def->controllers[i])))
+ char *devstr;
+ if (!(devstr = qemuBuildControllerDevStr(def->controllers[i])))
goto no_memory;
- ADD_ARG(scsi);
+ ADD_ARG(devstr);
}
}
--
1.6.6
14 years, 10 months