[libvirt] [PATCH] qemu: fix a crash when save file can't be opened
by Ján Tomko
In qemuDomainSaveMemory, wrapperFd might be NULL and should be checked before
calling virFileWrapperFdCatchError. Same in doCoreDump.
Bug: https://bugzilla.redhat.com/show_bug.cgi?id=880919
---
src/qemu/qemu_driver.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index c526f5f..7892293 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -2906,7 +2906,8 @@ qemuDomainSaveMemory(struct qemud_driver *driver,
cleanup:
VIR_FORCE_CLOSE(fd);
- virFileWrapperFdCatchError(wrapperFd);
+ if (wrapperFd)
+ virFileWrapperFdCatchError(wrapperFd);
virFileWrapperFdFree(wrapperFd);
VIR_FREE(xml);
@@ -3362,7 +3363,8 @@ doCoreDump(struct qemud_driver *driver,
cleanup:
VIR_FORCE_CLOSE(fd);
if (ret != 0) {
- virFileWrapperFdCatchError(wrapperFd);
+ if (wrapperFd)
+ virFileWrapperFdCatchError(wrapperFd);
unlink(path);
}
virFileWrapperFdFree(wrapperFd);
--
1.7.8.6
11 years, 12 months
[libvirt] [PATCHv2 0/3] util: capabilities detection for dnsmasq
by Laine Stump
This patch series resolves the libvirt part of CVE 2012-3411:
https://bugzilla.redhat.com/show_bug.cgi?id=833033
Further details are in PATCH 3/3.
The changes from V1 are all in PATCH 1/3 (resulting from Doug
Goldstein's review):
1) rework dnsmasqCapsRefresh() to create a new caps object if it's
given a NULL object (function now gets dnsmasqCapsPtr* instead of
dnsmasCapsPtr). This makes it possible to recover properly if dnsmasq
is installed after libvirtd has already been started.
2) Add the following before each run of dnsmasq:
virCommandAddEnvPassCommon(cmd);
virCommandClearCaps(cmd);
3) Fixed a missing space after comma :-)
11 years, 12 months
[libvirt] [PATCH v2] virsh: Rewrite cmdDomDisplay
by Martin Kletzander
Just a little rewrite of the cmdDomDisplay function to make it
consistent and hopefully more readable. This also fixes a problem
with password not being displayed for vnc even with the
"--include-password" option.
---
tools/virsh-domain.c | 132 +++++++++++++++++++++++++--------------------------
1 file changed, 64 insertions(+), 68 deletions(-)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index cc47383..1e8ccc9 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -7003,9 +7003,9 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd)
virDomainPtr dom;
virBuffer buf = VIR_BUFFER_INITIALIZER;
bool ret = false;
- char *doc;
- char *xpath;
- char *listen_addr;
+ char *doc = NULL;
+ char *xpath = NULL;
+ char *listen_addr = NULL;
int port, tls_port = 0;
char *passwd = NULL;
char *output = NULL;
@@ -7013,6 +7013,8 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd)
int iter = 0;
int tmp;
int flags = 0;
+ bool params = false;
+ const char *xpath_fmt = "string(/domain/devices/graphics[@type='%s']/@%s)";
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return false;
@@ -7025,109 +7027,95 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd)
if (vshCommandOptBool(cmd, "include-password"))
flags |= VIR_DOMAIN_XML_SECURE;
- doc = virDomainGetXMLDesc(dom, flags);
-
- if (!doc)
+ if (!(doc = virDomainGetXMLDesc(dom, flags)))
goto cleanup;
- xml = virXMLParseStringCtxt(doc, _("(domain_definition)"), &ctxt);
- VIR_FREE(doc);
- if (!xml)
+ if (!(xml = virXMLParseStringCtxt(doc, _("(domain_definition)"), &ctxt)))
goto cleanup;
/* Attempt to grab our display info */
for (iter = 0; scheme[iter] != NULL; iter++) {
/* Create our XPATH lookup for the current display's port */
- virAsprintf(&xpath, "string(/domain/devices/graphics[@type='%s']"
- "/@port)", scheme[iter]);
- if (!xpath) {
- virReportOOMError();
- goto cleanup;
- }
+ if (virAsprintf(&xpath, xpath_fmt, scheme[iter], "port") < 0)
+ goto no_memory;
/* Attempt to get the port number for the current graphics scheme */
tmp = virXPathInt(xpath, ctxt, &port);
VIR_FREE(xpath);
/* If there is no port number for this type, then jump to the next
- * scheme
- */
+ * scheme */
if (tmp)
continue;
/* Create our XPATH lookup for the current display's address */
- virAsprintf(&xpath, "string(/domain/devices/graphics[@type='%s']"
- "/@listen)", scheme[iter]);
- if (!xpath) {
- virReportOOMError();
- goto cleanup;
- }
+ if (virAsprintf(&xpath, xpath_fmt, scheme[iter], "listen") < 0)
+ goto no_memory;
/* Attempt to get the listening addr if set for the current
- * graphics scheme
- */
+ * graphics scheme */
listen_addr = virXPathString(xpath, ctxt);
VIR_FREE(xpath);
- /* Per scheme data mangling */
- if (STREQ(scheme[iter], "vnc")) {
- /* VNC protocol handlers take their port number as 'port' - 5900 */
+ /* We can query this info for all the graphics types since we'll
+ * get nothing for the unsupported ones (just rdp for now).
+ * Also the parameter '--include-password' was already taken
+ * care of when getting the XML */
+
+ /* Create our XPATH lookup for the password */
+ if (virAsprintf(&xpath, xpath_fmt, scheme[iter], "passwd") < 0)
+ goto no_memory;
+
+ /* Attempt to get the password */
+ passwd = virXPathString(xpath, ctxt);
+
+ if (STREQ(scheme[iter], "vnc"))
+ /* VNC protocol handlers take their port number as
+ * 'port' - 5900 */
port -= 5900;
- } else if (STREQ(scheme[iter], "spice")) {
- /* Create our XPATH lookup for the SPICE TLS Port */
- virAsprintf(&xpath, "string(/domain/devices/graphics[@type='%s']"
- "/@tlsPort)", scheme[iter]);
- if (!xpath) {
- virReportOOMError();
- goto cleanup;
- }
- /* Attempt to get the TLS port number for SPICE */
- tmp = virXPathInt(xpath, ctxt, &tls_port);
- VIR_FREE(xpath);
- if (tmp)
- tls_port = 0;
-
- if (vshCommandOptBool(cmd, "include-password")) {
- /* Create our XPATH lookup for the SPICE password */
- virAsprintf(&xpath, "string(/domain/devices/graphics"
- "[@type='%s']/@passwd)", scheme[iter]);
- if (!xpath) {
- virReportOOMError();
- goto cleanup;
- }
+ /* Create our XPATH lookup for TLS Port (automatically skipped
+ * for unsupported schemes */
+ if (virAsprintf(&xpath, xpath_fmt, scheme[iter], "tlsPort") < 0)
+ goto no_memory;
- /* Attempt to get the SPICE password */
- passwd = virXPathString(xpath, ctxt);
- VIR_FREE(xpath);
- }
- }
+ /* Attempt to get the TLS port number */
+ tmp = virXPathInt(xpath, ctxt, &tls_port);
+ VIR_FREE(xpath);
+ if (tmp)
+ tls_port = 0;
/* Build up the full URI, starting with the scheme */
virBufferAsprintf(&buf, "%s://", scheme[iter]);
+ /* There is no user, so just append password if there's any */
+ if (STREQ(scheme[iter], "vnc") && passwd)
+ virBufferAsprintf(&buf, ":%s@", passwd);
+
/* Then host name or IP */
if (!listen_addr || STREQ((const char *)listen_addr, "0.0.0.0"))
virBufferAddLit(&buf, "localhost");
else
virBufferAsprintf(&buf, "%s", listen_addr);
- VIR_FREE(listen_addr);
-
/* Add the port */
- if (STREQ(scheme[iter], "spice"))
- virBufferAsprintf(&buf, "?port=%d", port);
- else
- virBufferAsprintf(&buf, ":%d", port);
+ virBufferAsprintf(&buf, ":%d", port);
/* TLS Port */
- if (tls_port)
- virBufferAsprintf(&buf, "&tls-port=%d", tls_port);
+ if (tls_port) {
+ virBufferAsprintf(&buf,
+ "%stls-port=%d",
+ params ? "&" : "?",
+ tls_port);
+ params = true;
+ }
- /* Password */
- if (passwd) {
- virBufferAsprintf(&buf, "&password=%s", passwd);
- VIR_FREE(passwd);
+ if (STREQ(scheme[iter], "spice") && passwd) {
+ virBufferAsprintf(&buf,
+ "%spassword=%s",
+ params ? "&" : "?",
+ passwd);
+ params = true;
}
/* Ensure we can print our URI */
@@ -7139,7 +7127,6 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd)
/* Print out our full URI */
output = virBufferContentAndReset(&buf);
vshPrint(ctl, "%s", output);
- VIR_FREE(output);
/* We got what we came for so return successfully */
ret = true;
@@ -7147,10 +7134,19 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd)
}
cleanup:
+ VIR_FREE(doc);
+ VIR_FREE(xpath);
+ VIR_FREE(passwd);
+ VIR_FREE(listen_addr);
+ VIR_FREE(output);
xmlXPathFreeContext(ctxt);
xmlFreeDoc(xml);
virDomainFree(dom);
return ret;
+
+no_memory:
+ virReportOOMError();
+ goto cleanup;
}
/*
--
1.8.0
11 years, 12 months
[libvirt] [PATCH v1 00/11] Rework storage migration
by Michal Privoznik
This patch set re-implements migration with storage for enough new qemu.
Currently, you can migrate a domain to a host without need for shared storage.
This is done by setting 'blk' or 'inc' attribute (representing
VIR_MIGRATE_NON_SHARED_DISK and VIR_MIGRATE_NON_SHARED_INC flags respectively)
of 'migrate' monitor command. However, the qemu implementation is
buggy and applications are advised to switch to new impementation
which, moreover, offers some nice features, like migrating only explicitly
specified disks.
The new functionality is controlled via 'nbd-server-*' and 'drive-mirror'
commands. The flow is meant to look like this:
1) User invokes libvirt's migrate functionality.
2) libvirt checks that no block jobs are active on the source.
3) libvirt starts the destination QEMU and sets up the NBD server using the
nbd-server-start and nbd-server-add commands.
4) libvirt starts drive-mirror with a destination pointing to the remote NBD
server, for example nbd:host:port:exportname=diskname (where diskname is the
-drive id specified on the destination).
5) once all mirroring jobs reach steady state, libvirt invokes the migrate
command.
6) once migration completed, libvirt invokes the nbd-server-stop command on the
destination QEMU.
If we just skip the 2nd step and there is an active block-job, qemu will fail in
step 4. No big deal.
Since we try to NOT break migration and keep things compatible, this feature is
enabled iff both sides support it. Since there's obvious need for some data
transfer between src and dst, I've put it into qemuCookieMigration:
1) src -> dest: (QEMU_MIGRATION_PHASE_BEGIN3 -> QEMU_MIGRATION_PHASE_PREPARE)
<nbd>
<disk src='/var/lib/libvirt/images/f17.img' size='17179869184'/>
</nbd>
Hey destination, I know how to use this cool new feature. Moreover,
these are the paths I'll send you. Each file is X bytes big.
It's one of the prerequisite - the file on dst exists and has at least the
same size as on dst.
2) dst -> src: (QEMU_MIGRATION_PHASE_PREPARE -> QEMU_MIGRATION_PHASE_PERFORM3)
<nbd port='X'/>
Okay, I (destination) support this feature as well. I've created all
files as you (src) told me to and you can start rolling data. I am listening
on port X.
3) src -> dst: (QEMU_MIGRATION_PHASE_PERFORM3 -> QEMU_MIGRATION_PHASE_FINISH3)
<nbd port='-1'/>
Migration completed, destination, you may shut the NBD server down.
If either src or dst doesn't support NBD, it is not used and whole process fall
backs to old implementation.
Michal Privoznik (11):
qemu: Introduce NBD_SERVER capability
Introduce NBD migration cookie
qemu: Introduce nbd-server-start command
qemu: Introduce nbd-server-add command
qemu: Introduce nbd-server-stop command
qemu_migration: Introduce qemuMigrationStartNBDServer
qemu_migration: Move port allocation to a separate func
qemu_migration: Implement qemuMigrationStartNBDServer()
qemu_migration: Implement qemuMigrationDriveMirror
qemu_migration: Check size prerequisites
qemu_migration: Stop NBD server at Finish phase
src/qemu/qemu_capabilities.c | 3 +
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_driver.c | 8 +-
src/qemu/qemu_migration.c | 609 +++++++++++++++++++++++++++++++++++++++---
src/qemu/qemu_migration.h | 6 +-
src/qemu/qemu_monitor.c | 62 +++++
src/qemu/qemu_monitor.h | 6 +
src/qemu/qemu_monitor_json.c | 93 +++++++
src/qemu/qemu_monitor_json.h | 6 +
9 files changed, 756 insertions(+), 38 deletions(-)
--
1.7.8.6
11 years, 12 months
[libvirt] [PATCH v2 0/3] storage: allow metadata preallocation when creating qcow2 images
by Ján Tomko
Add support for preallocating metadata when creating qcow2 images.
Diff to V1:
* A flag for virStorageVolCreateXML and virStorageVolCreateXMLFrom
is used instead of guessing from the allocation element.
* The flag is exposed and documented in virsh.
Ján Tomko (3):
storage: add a flag for metadata preallocation to VolCreate
storage: allow metadata preallocation for qcow2 images
virsh: allow metadata preallocation when creating volumes
include/libvirt/libvirt.h.in | 4 +++
src/libvirt.c | 4 +-
src/storage/storage_backend.c | 46 ++++++++++++++++++++++++++-----------
src/storage/storage_backend.h | 3 +-
src/storage/storage_backend_fs.c | 16 ++++++++-----
src/storage/storage_driver.c | 6 ++--
tools/virsh-volume.c | 25 +++++++++++++++++---
tools/virsh.pod | 11 ++++++--
8 files changed, 82 insertions(+), 33 deletions(-)
--
1.7.8.6
11 years, 12 months
[libvirt] [PATCH 0/2] Minor doc/error message fixes
by Peter Krempa
Peter Krempa (2):
qemu: Fix error messages when dispatching guest agent commands
qemu: Drop word "either" from comments for agent monitor functions
src/qemu/qemu_agent.c | 11 ++++++-----
src/qemu/qemu_domain.c | 10 +++++-----
2 files changed, 11 insertions(+), 10 deletions(-)
--
1.8.0
11 years, 12 months
[libvirt] [PATCH 0/5] Support Ephemeral passthrough hostdevs
by Shradha Shah
The ephemeral flag helps support migration with PCI-passthrough.
An ephemeral hostdev is automatically unplugged before migration
and replugged (if one is available on the destination) after
migration.
Shradha Shah (5):
Added ephemeral flag for hostdev in domain conf.
Adding ephemeral flag for hostdev in network conf.
Ephemeral flag mofication within the network driver.
Ephemeral flag modification within the qemu driver.
Migration support for ephemeral hostdevs.
docs/schemas/domaincommon.rng | 16 ++++
docs/schemas/network.rng | 8 ++
src/conf/domain_conf.c | 23 +++++-
src/conf/domain_conf.h | 1 +
src/conf/network_conf.c | 11 +++
src/conf/network_conf.h | 1 +
src/network/bridge_driver.c | 1 +
src/qemu/qemu_command.c | 63 +++++++++-----
src/qemu/qemu_migration.c | 94 +++++++++++++++++++-
tests/networkxml2xmlin/hostdev-pf.xml | 2 +-
tests/networkxml2xmlin/hostdev.xml | 2 +-
tests/networkxml2xmlout/hostdev-pf.xml | 2 +-
tests/networkxml2xmlout/hostdev.xml | 2 +-
.../qemuxml2argv-hostdev-pci-address.xml | 2 +-
.../qemuxml2argv-hostdev-usb-address.xml | 2 +-
.../qemuxml2argvdata/qemuxml2argv-net-hostdev.xml | 2 +-
tests/qemuxml2argvdata/qemuxml2argv-pci-rom.xml | 4 +-
17 files changed, 200 insertions(+), 36 deletions(-)
--
1.7.4.4
11 years, 12 months
[libvirt] [PATCH 00/10 v3] Unprivileged SG_IO support
by Osier Yang
Hi,
As a result of RFC [1], this implements the unprivleged SG_IO
support. Testing is not that enough, but I'd like see the
reviewing earlier, and meanwhile I'm not going to give up
the further testing.
v2 - v3:
* Change the XML tag name to "cdbfilter"
* Maintain an internal list of shared disks for QEMU driver.
Patches 1/10 ~ 4/10 are to introduce the internal list for shared
disks.
Osier Yang (10):
qemu: Introduce a list to maintain the shared disks between domains
qemu: Init/Free the list with the driver's lifecyle
qemu: Add/remove the shared disk entry during domain's lifecyle
qemu: Add/Remove the entry of sharedDisks when live
attaching/detaching
docs: Add docs and rng schema for new XML cdbfilter
conf: Parse and format the new XML tag cdbfilter
util: Prepare helpers for unpriv_sgio setting
qemu: Manage disk's cdbfilter in domain's lifecycle
qemu: Do not restore the sysfs unpriv_sgio if the disk is being
shared
qemu: Error out when domain starting if the cdbfilter setting
conflicts
docs/formatdomain.html.in | 13 ++-
docs/schemas/domaincommon.rng | 52 +++++--
src/conf/domain_conf.c | 71 +++++++--
src/conf/domain_conf.h | 13 ++
src/libvirt_private.syms | 5 +
src/qemu/qemu_conf.c | 166 ++++++++++++++++++++
src/qemu/qemu_conf.h | 30 ++++
src/qemu/qemu_driver.c | 28 ++++
src/qemu/qemu_process.c | 103 ++++++++++++-
src/util/util.c | 145 +++++++++++++++++
src/util/util.h | 7 +
...ml2argv-disk-scsi-lun-passthrough-cdbfilter.xml | 32 ++++
tests/qemuxml2xmltest.c | 1 +
13 files changed, 634 insertions(+), 32 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-lun-passthrough-cdbfilter.xml
Regards,
Osier
11 years, 12 months
[libvirt] [PATCH 0/4] Introduce support for FITRIM within guest OS
by Michal Privoznik
https://bugzilla.redhat.com/show_bug.cgi?id=831159
Michal Privoznik (4):
Introduce virDomainFSTrim() public API
remote: Implement virDomainFSTrim
qemu: Implement virDomainFSTrim
virsh: Expose new virDomainFSTrim API
include/libvirt/libvirt.h.in | 4 ++
src/driver.h | 6 +++
src/libvirt.c | 50 +++++++++++++++++++++++++
src/libvirt_public.syms | 5 +++
src/qemu/qemu_agent.c | 25 +++++++++++++
src/qemu/qemu_agent.h | 2 +
src/qemu/qemu_driver.c | 83 ++++++++++++++++++++++++++++++++++++++++++
src/remote/remote_driver.c | 1 +
src/remote/remote_protocol.x | 10 +++++-
src/remote_protocol-structs | 7 ++++
src/rpc/gendispatch.pl | 1 +
tools/virsh-domain.c | 40 ++++++++++++++++++++
tools/virsh.pod | 12 ++++++
13 files changed, 245 insertions(+), 1 deletions(-)
--
1.7.8.6
11 years, 12 months
[libvirt] [PATCH v3] bitmap: fix typo to use UL type of integer constant in virBitmapIsAllSet
by Guannan Ren
This bug leads to getting incorrect vcpupin information via
qemudDomainGetVcpuPinInfo() API when the number of maximum
cpu on a host falls into a range such as 31 < ncpus < 64.
gcc warning:
left shift count >= width of type
The following bug is such the case
https://bugzilla.redhat.com/show_bug.cgi?id=876415
---
src/util/bitmap.c | 4 ++--
tests/virbitmaptest.c | 37 +++++++++++++++++++++++++++++++++++++
2 files changed, 39 insertions(+), 2 deletions(-)
diff --git a/src/util/bitmap.c b/src/util/bitmap.c
index 5ec5440..c29f5f3 100644
--- a/src/util/bitmap.c
+++ b/src/util/bitmap.c
@@ -574,8 +574,8 @@ bool virBitmapIsAllSet(virBitmapPtr bitmap)
return false;
if (unusedBits > 0) {
- if ((bitmap->map[sz] & ((1U << (VIR_BITMAP_BITS_PER_UNIT - unusedBits)) - 1))
- != ((1U << (VIR_BITMAP_BITS_PER_UNIT - unusedBits)) - 1))
+ if ((bitmap->map[sz] & ((1UL << (VIR_BITMAP_BITS_PER_UNIT - unusedBits)) - 1))
+ != ((1UL << (VIR_BITMAP_BITS_PER_UNIT - unusedBits)) - 1))
return false;
}
diff --git a/tests/virbitmaptest.c b/tests/virbitmaptest.c
index f1eb9d5..af94dab 100644
--- a/tests/virbitmaptest.c
+++ b/tests/virbitmaptest.c
@@ -347,6 +347,41 @@ error:
return ret;
}
+static int test7(const void *v ATTRIBUTE_UNUSED)
+{
+ virBitmapPtr bitmap;
+ size_t i;
+ size_t maxBit[] = {
+ 1, 8, 31, 32, 63, 64, 95, 96, 127, 128, 159, 160
+ };
+ size_t nmaxBit = 12;
+
+ for (i = 0; i < nmaxBit; i++) {
+ bitmap = virBitmapNew(maxBit[i]);
+ if (!bitmap)
+ goto error;
+
+ if (virBitmapIsAllSet(bitmap))
+ goto error;
+
+ ignore_value(virBitmapSetBit(bitmap, 1));
+ if (virBitmapIsAllSet(bitmap))
+ goto error;
+
+ virBitmapSetAll(bitmap);
+ if (!virBitmapIsAllSet(bitmap))
+ goto error;
+
+ virBitmapFree(bitmap);
+ }
+
+ return 0;
+
+error:
+ virBitmapFree(bitmap);
+ return -1;
+}
+
static int
mymain(void)
{
@@ -364,6 +399,8 @@ mymain(void)
ret = -1;
if (virtTestRun("test6", 1, test6, NULL) < 0)
ret = -1;
+ if (virtTestRun("test7", 1, test7, NULL) < 0)
+ ret = -1;
return ret;
--
1.7.11.2
11 years, 12 months