[libvirt] [PATCH 0/2] Resolve Coverity issues in vbox_tmpl.c
by John Ferlan
This pair of patches resolves what amount to false positives in the
vbox_tmpl.c code relating to attempts to dereference NULL in the 2002
VBOX_API_VERSION call to 'vboxIIDFromUUID()'. It also removes "false
postives" from the various VBOX_UTF*_FREE() macros. Some code paths
checked if the arg was valid prior to calling free. That triggered
Coverity into tagging other uses of the variables where the check wasn't
performed. While these changes resolve the Coverity issues there still
exists a "problem" where the VBOX_UTF<n>_TO_UTF<m> macros don't check the
return status from the called function nor does the code that uses the
macros always check the returned arg2 for validity (125 occurrances).
John Ferlan (2):
vbox: Address false positive for NULL dereference
vbox: Adjust the UTF FREE macros
src/vbox/vbox_tmpl.c | 77 ++++++++++++++++++++++++++--------------------------
1 file changed, 38 insertions(+), 39 deletions(-)
--
1.7.11.7
11 years, 10 months
[libvirt] [PATCH] Make sure we only abort without libcurl if $with_esx = yes
by Guido Günther
---
configure.ac | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index 712918f..4bd3c3e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1810,7 +1810,7 @@ dnl check for (ESX)
dnl
if test "$with_curl" != "yes" ; then
- if test "$with_esx" = "check"; then
+ if test "$with_esx" != "yes"; then
with_esx=no
else
AC_MSG_ERROR([Curl is required for the ESX driver])
--
1.7.10.4
11 years, 10 months
[libvirt] [PATCH] virsh: Add --print-xml flag for attach-disk command
by Peter Krempa
The flag causes the XML of the disk that would be attached to be printed
instead.
---
tools/virsh-domain.c | 46 ++++++++++++++++++++++++++++------------------
tools/virsh.pod | 5 ++++-
2 files changed, 32 insertions(+), 19 deletions(-)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 026dac1..829e475 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -317,6 +317,12 @@ static const vshCmdOptDef opts_attach_disk[] = {
.flags = 0,
.help = N_("use multifunction pci under specified address")
},
+ {.name = "print-xml",
+ .type = VSH_OT_BOOL,
+ .flags = 0,
+ .help = N_("print XML document rather than attach the disk")
+ },
+
{.name = NULL}
};
@@ -480,11 +486,11 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
unsigned int flags;
const char *stype = NULL;
virBuffer buf = VIR_BUFFER_INITIALIZER;
- char *xml;
+ char *xml = NULL;
struct stat st;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
- goto cleanup;
+ return false;
if (vshCommandOptString(cmd, "source", &source) <= 0)
goto cleanup;
@@ -620,27 +626,31 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
xml = virBufferContentAndReset(&buf);
- if (vshCommandOptBool(cmd, "config")) {
- flags = VIR_DOMAIN_AFFECT_CONFIG;
- if (virDomainIsActive(dom) == 1)
- flags |= VIR_DOMAIN_AFFECT_LIVE;
- ret = virDomainAttachDeviceFlags(dom, xml, flags);
- } else {
- ret = virDomainAttachDevice(dom, xml);
- }
-
- VIR_FREE(xml);
+ if (!vshCommandOptBool(cmd, "print-xml")) {
+ if (vshCommandOptBool(cmd, "config")) {
+ flags = VIR_DOMAIN_AFFECT_CONFIG;
+ if (virDomainIsActive(dom) == 1)
+ flags |= VIR_DOMAIN_AFFECT_LIVE;
+ ret = virDomainAttachDeviceFlags(dom, xml, flags);
+ } else {
+ ret = virDomainAttachDevice(dom, xml);
+ }
- if (ret != 0) {
- vshError(ctl, "%s", _("Failed to attach disk"));
+ if (ret != 0) {
+ vshError(ctl, "%s", _("Failed to attach disk"));
+ goto cleanup;
+ } else {
+ vshPrint(ctl, "%s", _("Disk attached successfully\n"));
+ }
} else {
- vshPrint(ctl, "%s", _("Disk attached successfully\n"));
- functionReturn = true;
+ vshPrint(ctl, "%s", xml);
}
+ functionReturn = true;
+
cleanup:
- if (dom)
- virDomainFree(dom);
+ VIR_FREE(xml);
+ virDomainFree(dom);
virBufferFreeAndReset(&buf);
return functionReturn;
}
diff --git a/tools/virsh.pod b/tools/virsh.pod
index e2a2aec..fd0f762 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -1787,7 +1787,7 @@ needed if the device does not use managed mode.
[I<--driver driver>] [I<--subdriver subdriver>] [I<--cache cache>]
[I<--type type>] [I<--mode mode>] [I<--config>] [I<--sourcetype soucetype>]
[I<--serial serial>] [I<--shareable>] [I<--rawio>] [I<--address address>]
-[I<--multifunction>]
+[I<--multifunction>] [I<--print-xml>]
Attach a new disk device to the domain.
I<source> is path for the files and devices. I<target> controls the bus or
@@ -1817,6 +1817,9 @@ scsi:controller.bus.unit or ide:controller.bus.unit.
I<multifunction> indicates specified pci address is a multifunction pci device
address.
+If I<--print-xml> is specified, then the XML of the disk that would be attached
+is printed instead.
+
=item B<attach-interface> I<domain> I<type> I<source>
[I<--target target>] [I<--mac mac>] [I<--script script>] [I<--model model>]
[I<--config>] [I<--inbound average,peak,burst>] [I<--outbound average,peak,burst>]
--
1.8.1.1
11 years, 10 months
[libvirt] [PATCH 0/6] libxl bug and race fixes
by Jim Fehlig
This series fixes several bugs and races in the libxl driver, as
described in the commit messages of the individual patches.
One of the races was discussed on the xen-devel ml [1] and resulted
in two fixes in libxl [2,3]. I've tested this series with and without
the libxl patches. All of the previously discovered races are fixed
with this series and the libxl patches. It is possible to fire asserts
in libxl with this series and without the libxl patches, but that is no
worse than the current behavior.
The libxl patches have not yet been committed upstream, hence the
'XXXX' for commit id in patch 1. I will respond to the xen-devel
thread now with an ACK on the libxl patches (and a reference to this
series) so those can be committed. I'll fixup the commit message for
patch 1 later, but wanted to get this series on the list for review
before the 1.0.2 freeze.
[1] http://lists.xen.org/archives/html/xen-devel/2012-11/msg01016.html
[2] http://lists.xen.org/archives/html/xen-devel/2012-12/msg00684.html
[3] http://lists.xen.org/archives/html/xen-devel/2012-12/msg00685.html
Jim Fehlig (6):
libxl: Fix handling of timeouts
libxl: Fix races in libxl event code
libxl: Fix race between destruction of objects
libxl: Explicitly remove timeouts
libxl: Fix removing non-persistent domain after save
libxl: Find domain object in event handler
src/libxl/libxl_conf.h | 9 ++
src/libxl/libxl_driver.c | 298 ++++++++++++++++++++++++++++++++++-------------
2 files changed, 226 insertions(+), 81 deletions(-)
--
1.8.0.1
11 years, 10 months
[libvirt] [PATCH v2] python: Fix bindings for virDomainSnapshotGet{Domain, Connect}
by Jiri Denemark
https://bugzilla.redhat.com/show_bug.cgi?id=895882
virDomainSnapshot.getDomain() and virDomainSnapshot.getConnect()
wrappers around virDomainSnapshotGet{Domain,Connect} were not supposed
to be ever implemented. The class should contain proper domain() and
connect() accessors that fetch python objects stored internally within
the class. While domain() was already provided, connect() was missing.
This patch adds connect() method to virDomainSnapshot class and
reimplements getDomain() and getConnect() methods as aliases to domain()
and connect() for backward compatibility.
---
python/generator.py | 4 +++-
python/libvirt-override-virDomainSnapshot.py | 8 ++++++++
src/libvirt.c | 10 ++++++++--
3 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/python/generator.py b/python/generator.py
index f853d77..5894616 100755
--- a/python/generator.py
+++ b/python/generator.py
@@ -527,6 +527,8 @@ skip_function = (
"virNWFilterGetConnect",
"virStoragePoolGetConnect",
"virStorageVolGetConnect",
+ "virDomainSnapshotGetConnect",
+ "virDomainSnapshotGetDomain",
# only useful in C code, python code uses dict for typed parameters
"virTypedParamsAddBoolean",
@@ -953,7 +955,6 @@ classes_destructors = {
class_skip_connect_impl = {
"virConnect" : True,
- "virDomainSnapshot": True,
}
class_domain_impl = {
@@ -1436,6 +1437,7 @@ def buildWrappers(module):
" self._conn = conn._conn\n")
elif classname in [ "virDomainSnapshot" ]:
classes.write(" self._dom = dom\n")
+ classes.write(" self._conn = dom.connect()\n")
classes.write(" if _obj != None:self._o = _obj;return\n")
classes.write(" self._o = None\n\n");
destruct=None
diff --git a/python/libvirt-override-virDomainSnapshot.py b/python/libvirt-override-virDomainSnapshot.py
index 3da7bfd..bf708a5 100644
--- a/python/libvirt-override-virDomainSnapshot.py
+++ b/python/libvirt-override-virDomainSnapshot.py
@@ -1,3 +1,11 @@
+ def getConnect(self):
+ """Get the connection that owns the domain that a snapshot was created for"""
+ return self.connect()
+
+ def getDomain(self):
+ """Get the domain that a snapshot was created for"""
+ return self.domain()
+
def listAllChildren(self, flags):
"""List all child snapshots and returns a list of snapshot objects"""
ret = libvirtmod.virDomainSnapshotListAllChildren(self._o, flags)
diff --git a/src/libvirt.c b/src/libvirt.c
index d5d561c..fa39881 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -17850,7 +17850,10 @@ virDomainSnapshotGetName(virDomainSnapshotPtr snapshot)
* virDomainSnapshotGetDomain:
* @snapshot: a snapshot object
*
- * Get the domain that a snapshot was created for
+ * Get the domain that a snapshot was created for.
+ *
+ * WARNING: When writing libvirt bindings in other languages, do not use this
+ * function. Instead, store the domain and the snapshot object together.
*
* Returns the domain or NULL.
*/
@@ -17874,7 +17877,10 @@ virDomainSnapshotGetDomain(virDomainSnapshotPtr snapshot)
* virDomainSnapshotGetConnect:
* @snapshot: a snapshot object
*
- * Get the connection that owns the domain that a snapshot was created for
+ * Get the connection that owns the domain that a snapshot was created for.
+ *
+ * WARNING: When writing libvirt bindings in other languages, do not use this
+ * function. Instead, store the connection and the snapshot object together.
*
* Returns the connection or NULL.
*/
--
1.8.1.1
11 years, 10 months
[libvirt] Entering freeze for libvirt-1.0.2
by Daniel Veillard
As scheduled and to gte a release by the end of the month next
week, I have just tagged a release candidate 1 version in git and
pushed associated tarballs and rpms to the usual place:
ftp://libvirt.org/libvirt/
please give it a try and let's ocuse on fixing bugs untl the freeze
end. I will probably make a release candidate 2 on Monday, and if
everything goes well rol out the 1.0.2 release on Wednesday or Thursday.
thanks !
Daniel
--
Daniel Veillard | Open Source and Standards, Red Hat
veillard(a)redhat.com | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
http://veillard.com/ | virtualization library http://libvirt.org/
11 years, 10 months
[libvirt] [PATCH] conf: avoid NULL deref for pmsuspended domain state
by Eric Blake
While working with a pmsuspend vs. snapshot issue, I noticed that
the state file in /var/run/libvirt/qemu/dom.xml contained a rather
suspicious "(null)" string, which does not round-trip well through
a libvirtd restart. Had I been on a platform other than glibc
where printf("%s",NULL) crashes instead of printing (null), we might
have noticed the problem much sooner.
And in fixing that problem, I also noticed that we had several
missing states, because we were #defining several *_LAST names
to a value _different_ than what they were already given as enums
in libvirt.h. Yuck. I got rid of default: labels in the case
statements, because they get in the way of gcc's -Wswitch helping
us ensure we cover all enum values.
* src/conf/domain_conf.c (virDomainStateReasonToString)
(virDomainStateReasonFromString): Fill in missing domain states;
rewrite case statement to let compiler enforce checking.
(VIR_DOMAIN_NOSTATE_LAST, VIR_DOMAIN_RUNNING_LAST)
(VIR_DOMAIN_BLOCKED_LAST, VIR_DOMAIN_PAUSED_LAST)
(VIR_DOMAIN_SHUTDOWN_LAST, VIR_DOMAIN_SHUTOFF_LAST)
(VIR_DOMAIN_CRASHED_LAST): Drop dead defines.
(VIR_DOMAIN_PMSUSPENDED_LAST): Drop dead define.
(virDomainPMSuspendedReason): Add missing enum function.
(virDomainRunningReason, virDomainPausedReason): Add missing enum
value.
* src/conf/domain_conf.h (virDomainPMSuspendedReason): Declare
missing functions.
* src/libvirt_private.syms (domain_conf.h): Export them.
---
src/conf/domain_conf.c | 32 +++++++++++++++++++-------------
src/conf/domain_conf.h | 1 +
src/libvirt_private.syms | 6 ++++--
3 files changed, 24 insertions(+), 15 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 7273790..5782abb 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -574,11 +574,9 @@ VIR_ENUM_IMPL(virDomainState, VIR_DOMAIN_LAST,
"crashed",
"pmsuspended")
-#define VIR_DOMAIN_NOSTATE_LAST (VIR_DOMAIN_NOSTATE_UNKNOWN + 1)
VIR_ENUM_IMPL(virDomainNostateReason, VIR_DOMAIN_NOSTATE_LAST,
"unknown")
-#define VIR_DOMAIN_RUNNING_LAST (VIR_DOMAIN_RUNNING_SAVE_CANCELED + 1)
VIR_ENUM_IMPL(virDomainRunningReason, VIR_DOMAIN_RUNNING_LAST,
"unknown",
"booted",
@@ -587,13 +585,12 @@ VIR_ENUM_IMPL(virDomainRunningReason, VIR_DOMAIN_RUNNING_LAST,
"from snapshot",
"unpaused",
"migration canceled",
- "save canceled")
+ "save canceled",
+ "wakeup")
-#define VIR_DOMAIN_BLOCKED_LAST (VIR_DOMAIN_BLOCKED_UNKNOWN + 1)
VIR_ENUM_IMPL(virDomainBlockedReason, VIR_DOMAIN_BLOCKED_LAST,
"unknown")
-#define VIR_DOMAIN_PAUSED_LAST (VIR_DOMAIN_PAUSED_SHUTTING_DOWN + 1)
VIR_ENUM_IMPL(virDomainPausedReason, VIR_DOMAIN_PAUSED_LAST,
"unknown",
"user",
@@ -603,14 +600,13 @@ VIR_ENUM_IMPL(virDomainPausedReason, VIR_DOMAIN_PAUSED_LAST,
"ioerror",
"watchdog",
"from snapshot",
- "shutdown")
+ "shutdown",
+ "snapshot")
-#define VIR_DOMAIN_SHUTDOWN_LAST (VIR_DOMAIN_SHUTDOWN_USER + 1)
VIR_ENUM_IMPL(virDomainShutdownReason, VIR_DOMAIN_SHUTDOWN_LAST,
"unknown",
"user")
-#define VIR_DOMAIN_SHUTOFF_LAST (VIR_DOMAIN_SHUTOFF_FROM_SNAPSHOT + 1)
VIR_ENUM_IMPL(virDomainShutoffReason, VIR_DOMAIN_SHUTOFF_LAST,
"unknown",
"shutdown",
@@ -621,10 +617,12 @@ VIR_ENUM_IMPL(virDomainShutoffReason, VIR_DOMAIN_SHUTOFF_LAST,
"failed",
"from snapshot")
-#define VIR_DOMAIN_CRASHED_LAST (VIR_DOMAIN_CRASHED_UNKNOWN + 1)
VIR_ENUM_IMPL(virDomainCrashedReason, VIR_DOMAIN_CRASHED_LAST,
"unknown")
+VIR_ENUM_IMPL(virDomainPMSuspendedReason, VIR_DOMAIN_PMSUSPENDED_LAST,
+ "unknown")
+
VIR_ENUM_IMPL(virDomainSeclabel, VIR_DOMAIN_SECLABEL_LAST,
"default",
"none",
@@ -15438,9 +15436,13 @@ virDomainStateReasonToString(virDomainState state, int reason)
return virDomainShutoffReasonTypeToString(reason);
case VIR_DOMAIN_CRASHED:
return virDomainCrashedReasonTypeToString(reason);
- default:
- return NULL;
+ case VIR_DOMAIN_PMSUSPENDED:
+ return virDomainPMSuspendedReasonTypeToString(reason);
+ case VIR_DOMAIN_LAST:
+ break;
}
+ VIR_WARN("Unexpected domain state: %d", state);
+ return NULL;
}
@@ -15462,9 +15464,13 @@ virDomainStateReasonFromString(virDomainState state, const char *reason)
return virDomainShutoffReasonTypeFromString(reason);
case VIR_DOMAIN_CRASHED:
return virDomainCrashedReasonTypeFromString(reason);
- default:
- return -1;
+ case VIR_DOMAIN_PMSUSPENDED:
+ return virDomainPMSuspendedReasonTypeFromString(reason);
+ case VIR_DOMAIN_LAST:
+ break;
}
+ VIR_WARN("Unexpected domain state: %d", state);
+ return -1;
}
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index abbfe86..9a9e0b1 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2315,6 +2315,7 @@ VIR_ENUM_DECL(virDomainPausedReason)
VIR_ENUM_DECL(virDomainShutdownReason)
VIR_ENUM_DECL(virDomainShutoffReason)
VIR_ENUM_DECL(virDomainCrashedReason)
+VIR_ENUM_DECL(virDomainPMSuspendedReason)
const char *virDomainStateReasonToString(virDomainState state, int reason);
int virDomainStateReasonFromString(virDomainState state, const char *reason);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index fc23adc..57ecc36 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -487,10 +487,12 @@ virDomainObjSetState;
virDomainObjTaint;
virDomainPausedReasonTypeFromString;
virDomainPausedReasonTypeToString;
-virDomainPciRombarModeTypeFromString;
-virDomainPciRombarModeTypeToString;
virDomainPMStateTypeFromString;
virDomainPMStateTypeToString;
+virDomainPMSuspendedReasonTypeFromString;
+virDomainPMSuspendedReasonTypeToString;
+virDomainPciRombarModeTypeFromString;
+virDomainPciRombarModeTypeToString;
virDomainRedirdevBusTypeFromString;
virDomainRedirdevBusTypeToString;
virDomainRemoveInactive;
--
1.8.1
11 years, 10 months
[libvirt] [PATCH] Fix performance & reliabilty of QMP probing
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
This previous commit
commit 1a50ba2cb07d8bb2aa724062889deb9efd7ad9e9
Author: Viktor Mihajlovski <mihajlov(a)linux.vnet.ibm.com>
Date: Mon Nov 26 15:17:13 2012 +0100
qemu: Fix QMP Capabability Probing Failure
which attempted to make sure the QEMU process used for probing
ran as the right user id, caused serious performance regression
and unreliability in probing. The -daemonize switch in QEMU
guarantees that the monitor socket is present before the parent
process exits. This means libvirtd is guaranteed to be able to
connect immediately. By switching from -daemonize to the
virCommandDaemonize API libvirtd was no longer synchronized with
QEMU's startup process. The result was that the QEMU monitor
failed to open and went into its 200ms sleep loop. This happened
for all 25 binaries resulting in 5 seconds worth of sleeping
at libvirtd startup. In addition sometimes when libvirt connected,
QEMU would be partially initialized and crash causing total
failure to probe that binary.
This commit reverts the previous change, ensuring we do use the
-daemonize flag to QEMU. Startup delay is cut from 7 seconds
to 2 seconds on my machine, which is on a par with what it was
prior to the capabilities rewrite.
To deal with the fact that QEMU needs to be able to create the
pidfile, we switch pidfile location fron runDir to libDir, which
QEMU is guaranteed to be able to write to.
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
src/qemu/qemu_capabilities.c | 50 ++++++++++++++++++++++++++++++--------------
src/qemu/qemu_capabilities.h | 3 +--
2 files changed, 35 insertions(+), 18 deletions(-)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 95fa3da..703179d 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -38,6 +38,7 @@
#include "virbitmap.h"
#include "virnodesuspend.h"
#include "qemu_monitor.h"
+#include "virtime.h"
#include <sys/stat.h>
#include <unistd.h>
@@ -916,11 +917,19 @@ virCapsPtr qemuCapsInit(qemuCapsCachePtr cache)
* so just probe for them all - we gracefully fail
* if a qemu-system-$ARCH binary can't be found
*/
- for (i = 0 ; i < VIR_ARCH_LAST ; i++)
+ unsigned long long a, b;
+ for (i = 0 ; i < VIR_ARCH_LAST ; i++) {
+ unsigned long long start, end;
+ if (virTimeMillisNow(&start) < 0)
+ goto error;
if (qemuCapsInitGuest(caps, cache,
virArchFromHost(),
i) < 0)
goto error;
+ if (virTimeMillisNow(&end) < 0)
+ goto error;
+ VIR_DEBUG("Probed %s in %llums", virArchToString(i), end-start);
+ }
/* QEMU Requires an emulator in the XML */
virCapabilitiesSetEmulatorRequired(caps);
@@ -2291,7 +2300,6 @@ qemuCapsInitQMPBasic(qemuCapsPtr caps)
static int
qemuCapsInitQMP(qemuCapsPtr caps,
const char *libDir,
- const char *runDir,
uid_t runUid,
gid_t runGid)
{
@@ -2324,8 +2332,11 @@ qemuCapsInitQMP(qemuCapsPtr caps,
/* ".pidfile" suffix is used rather than ".pid" to avoid a possible clash
* with a qemu domain called "capabilities"
+ * Normally we'd use runDir for pid files, but because we're using
+ * -daemonize we need QEMU to be allowed to create them, rather
+ * than libvirtd. So we're using libDir which QEMU can write to
*/
- if (virAsprintf(&pidfile, "%s/%s", runDir, "capabilities.pidfile") < 0) {
+ if (virAsprintf(&pidfile, "%s/%s", libDir, "capabilities.pidfile") < 0) {
virReportOOMError();
goto cleanup;
}
@@ -2337,6 +2348,13 @@ qemuCapsInitQMP(qemuCapsPtr caps,
VIR_DEBUG("Try to get caps via QMP caps=%p", caps);
+ /*
+ * We explicitly need to use -daemonize here, rather than
+ * virCommandDaemonize, because we need to synchronize
+ * with QEMU creating its monitor socket API. Using
+ * daemonize guarnatees control won't return to libvirt
+ * until the socket is present.
+ */
cmd = virCommandNewArgList(caps->binary,
"-S",
"-no-user-config",
@@ -2344,14 +2362,14 @@ qemuCapsInitQMP(qemuCapsPtr caps,
"-nographic",
"-M", "none",
"-qmp", monarg,
+ "-pidfile", pidfile,
+ "-daemonize",
NULL);
virCommandAddEnvPassCommon(cmd);
virCommandClearCaps(cmd);
hookData.runUid = runUid;
hookData.runGid = runGid;
virCommandSetPreExecHook(cmd, qemuCapsHook, &hookData);
- virCommandSetPidFile(cmd, pidfile);
- virCommandDaemonize(cmd);
if (virCommandRun(cmd, &status) < 0)
goto cleanup;
@@ -2472,7 +2490,6 @@ cleanup:
qemuCapsPtr qemuCapsNewForBinary(const char *binary,
const char *libDir,
- const char *runDir,
uid_t runUid,
gid_t runGid)
{
@@ -2502,12 +2519,14 @@ qemuCapsPtr qemuCapsNewForBinary(const char *binary,
goto error;
}
- if ((rv = qemuCapsInitQMP(caps, libDir, runDir, runUid, runGid)) < 0)
+ if ((rv = qemuCapsInitQMP(caps, libDir, runUid, runGid)) < 0)
goto error;
- if (!caps->usedQMP &&
- qemuCapsInitHelp(caps, runUid, runGid) < 0)
- goto error;
+ if (!caps->usedQMP) {
+ VIR_ERROR("Falling back to help");
+ if (qemuCapsInitHelp(caps, runUid, runGid) < 0)
+ goto error;
+ }
return caps;
@@ -2542,8 +2561,9 @@ qemuCapsHashDataFree(void *payload, const void *key ATTRIBUTE_UNUSED)
qemuCapsCachePtr
-qemuCapsCacheNew(const char *libDir, const char *runDir,
- uid_t runUid, gid_t runGid)
+qemuCapsCacheNew(const char *libDir,
+ uid_t runUid,
+ gid_t runGid)
{
qemuCapsCachePtr cache;
@@ -2561,8 +2581,7 @@ qemuCapsCacheNew(const char *libDir, const char *runDir,
if (!(cache->binaries = virHashCreate(10, qemuCapsHashDataFree)))
goto error;
- if (!(cache->libDir = strdup(libDir)) ||
- !(cache->runDir = strdup(runDir))) {
+ if (!(cache->libDir = strdup(libDir))) {
virReportOOMError();
goto error;
}
@@ -2594,7 +2613,7 @@ qemuCapsCacheLookup(qemuCapsCachePtr cache, const char *binary)
if (!ret) {
VIR_DEBUG("Creating capabilities for %s",
binary);
- ret = qemuCapsNewForBinary(binary, cache->libDir, cache->runDir,
+ ret = qemuCapsNewForBinary(binary, cache->libDir,
cache->runUid, cache->runGid);
if (ret) {
VIR_DEBUG("Caching capabilities %p for %s",
@@ -2634,7 +2653,6 @@ qemuCapsCacheFree(qemuCapsCachePtr cache)
return;
VIR_FREE(cache->libDir);
- VIR_FREE(cache->runDir);
virHashFree(cache->binaries);
virMutexDestroy(&cache->lock);
VIR_FREE(cache);
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 089fa30..5279d07 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -179,7 +179,6 @@ qemuCapsPtr qemuCapsNew(void);
qemuCapsPtr qemuCapsNewCopy(qemuCapsPtr caps);
qemuCapsPtr qemuCapsNewForBinary(const char *binary,
const char *libDir,
- const char *runDir,
uid_t runUid,
gid_t runGid);
@@ -219,7 +218,7 @@ int qemuCapsGetMachineTypesCaps(qemuCapsPtr caps,
bool qemuCapsIsValid(qemuCapsPtr caps);
-qemuCapsCachePtr qemuCapsCacheNew(const char *libDir, const char *runDir,
+qemuCapsCachePtr qemuCapsCacheNew(const char *libDir,
uid_t uid, gid_t gid);
qemuCapsPtr qemuCapsCacheLookup(qemuCapsCachePtr cache, const char *binary);
qemuCapsPtr qemuCapsCacheLookupCopy(qemuCapsCachePtr cache, const char *binary);
--
1.8.0.2
11 years, 10 months
[libvirt] [Openstack][Sheepdog][Libvirt][Qemu]Add a new block storage driver by Libvirt/Qemu way for Openstack
by harryxiyou
Hi all,
I wanna add a new block storage driver by Libvirt/Qemu way for Openstack, which
is as same as Sheepdog driver for Openstack. So i think the theories
are like this.
1, In the Openstack Nova branch, Openstck driver call libvirt client
and send parameters
to libvirt client.(From this point, i should modify Openstack Nova
source codes. They are
a, nova/nova/virt/libvirt/driver.py add new driver way
b, /OpenStack/nova/nova/tests/test_libvirt.py add new driver test)
2, According to own protocol, libvirt client in Openstack Nova branch
send parameters to
Libvirt server.(From this point, i should modify libvirt library to
let libvirt library support this
new driver like Sheepdog).
3, Libvirt server call Qemu interfaces to send parameters to
Qemu.(From this point, i should
modify Qemu source codes to let Qemu support this new driver like Sheepdog).
4, In Openstack Cinder branch, Openstack driver use Qemu commands to
create this new volumes
to Qemu.(From this point, i should modify Openstack Cinder branch
source codes like this.
a, Add new driver file
/OpenStack/cinder/cinder/volume/drivers/new_driver.py like Sheepdog.py
b, Change file /OpenStack/cinder/cinder/tests/test_drivers_compatibility.py
to test new driver).
5, At last, i should also modify
/OpenStack/manuals/doc/src/docbkx/openstack-compute-admin/tables/hypervisors-nova-conf.xml
to configure this new driver.
Are my theories right? Should i do any other stuffs? Could anyone give
me any other suggestions?
Thanks in advance ;-)
--
Thanks
Harry Wei
11 years, 10 months
[libvirt] [PATCH] virsh: Forbid usage of --memspec and --disk-only together
by Peter Krempa
virsh snapshot-create-as with --memspec and --disk only fails at the
qemu driver. Forbid the creation at virsh too and document it.
---
tools/virsh-snapshot.c | 6 ++++++
tools/virsh.pod | 3 ++-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/tools/virsh-snapshot.c b/tools/virsh-snapshot.c
index e4745d6..86fd1fd 100644
--- a/tools/virsh-snapshot.c
+++ b/tools/virsh-snapshot.c
@@ -457,6 +457,12 @@ cmdSnapshotCreateAs(vshControl *ctl, const vshCmd *cmd)
goto cleanup;
}
+ if (memspec && (flags & VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY)) {
+ vshError(ctl, "%s",
+ _("Can't combine disk only snapshots with --memspec"));
+ goto cleanup;
+ }
+
if (memspec && vshParseSnapshotMemspec(ctl, &buf, memspec) < 0)
goto cleanup;
diff --git a/tools/virsh.pod b/tools/virsh.pod
index e2a2aec..c5cf16c 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -2746,7 +2746,8 @@ The I<--memspec> option can be used to control whether a checkpoint
is internal or external. The I<--memspec> flag is mandatory, followed
by a B<memspec> of the form B<[file=]name[,snapshot=type]>, where
type can be B<none>, B<internal>, or B<external>. To include a literal
-comma in B<file=name>, escape it with a second comma.
+comma in B<file=name>, escape it with a second comma. I<--memspec> cannot
+be used together with I<--disk-only>.
The I<--diskspec> option can be used to control how I<--disk-only> and
external checkpoints create external files. This option can occur
--
1.8.1.1
11 years, 10 months