[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
15 years, 2 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
15 years, 2 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
15 years, 2 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
15 years, 2 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
15 years, 2 months