[libvirt] [PATCH] vl: allow "cont" from panicked state
by Paolo Bonzini
After reporting the GUEST_PANICKED monitor event, QEMU stops the VM.
The reason for this is that events are edge-triggered, and can be lost if
management dies at the wrong time. Stopping a panicked VM lets management
know of a panic even if it has crashed; management can learn about the
panic when it restarts and queries running QEMU processes. The downside
is of course that the VM will be paused while management is not running,
but that is acceptable if it only happens with explicit "-device pvpanic".
Upon learning of a panic, management (if configured to do so) can pick a
variety of behaviors: leave the VM paused, reset it, destroy it. In
addition to all of these behaviors, it is possible dumping the VM core
from the host.
However, right now, the panicked state is irreversible, and can only be
exited by resetting the machine. This means that any policy decision
is entirely in the hands of the host. In particular there is no way to
use the "reboot on panic" option together with pvpanic.
This patch makes the panicked state reversible (and removes various
workarounds that were there because of the state being irreversible).
With this change, management has a wider set of possible policies: it
can just log the crash and leave policy to the guest, it can leave the
VM paused. In particular, the "log the crash and continue" is implemented
simply by sending a "cont" as soon as management learns about the panic.
Management could also implement the "irreversible paused state" itself.
And again, all such actions can be coupled with dumping the VM core.
Unfortunately we cannot change the behavior of 1.6.0. Thus, even if
it uses "-device pvpanic", management should check for "cont" failures.
If "cont" fails, management can then log that the VM remained paused
and urge the administrator to update QEMU.
I suggest that this patch be included in an 1.6.1 release as soon as
possible, and perhaps in the 1.5 branch too.
Cc: qemu-stable(a)nongnu.org
Signed-off-by: Paolo Bonzini <pbonzini(a)redhat.com>
---
gdbstub.c | 3 ---
vl.c | 6 ++----
2 files changed, 2 insertions(+), 7 deletions(-)
diff --git a/gdbstub.c b/gdbstub.c
index 35ca7c2..747e67d 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -372,9 +372,6 @@ static inline void gdb_continue(GDBState *s)
#ifdef CONFIG_USER_ONLY
s->running_state = 1;
#else
- if (runstate_check(RUN_STATE_GUEST_PANICKED)) {
- runstate_set(RUN_STATE_DEBUG);
- }
if (!runstate_needs_reset()) {
vm_start();
}
diff --git a/vl.c b/vl.c
index 25b8f2f..818d99e 100644
--- a/vl.c
+++ b/vl.c
@@ -637,9 +637,8 @@ static const RunStateTransition runstate_transitions_def[] = {
{ RUN_STATE_WATCHDOG, RUN_STATE_RUNNING },
{ RUN_STATE_WATCHDOG, RUN_STATE_FINISH_MIGRATE },
- { RUN_STATE_GUEST_PANICKED, RUN_STATE_PAUSED },
+ { RUN_STATE_GUEST_PANICKED, RUN_STATE_RUNNING },
{ RUN_STATE_GUEST_PANICKED, RUN_STATE_FINISH_MIGRATE },
- { RUN_STATE_GUEST_PANICKED, RUN_STATE_DEBUG },
{ RUN_STATE_MAX, RUN_STATE_MAX },
};
@@ -685,8 +684,7 @@ int runstate_is_running(void)
bool runstate_needs_reset(void)
{
return runstate_check(RUN_STATE_INTERNAL_ERROR) ||
- runstate_check(RUN_STATE_SHUTDOWN) ||
- runstate_check(RUN_STATE_GUEST_PANICKED);
+ runstate_check(RUN_STATE_SHUTDOWN);
}
StatusInfo *qmp_query_status(Error **errp)
--
1.8.3.1
11 years, 2 months
[libvirt] [PATCH] docs: Reformat <disk> attribute description in formatdomain
by John Ferlan
Reformat the description to more cleanly delineate the attributes
for a <disk> element.
---
Similar to the recently changed <source> attribute.
docs/formatdomain.html.in | 121 +++++++++++++++++++++++++++-------------------
1 file changed, 71 insertions(+), 50 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 0d1a74f..9d12293 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -1562,56 +1562,77 @@
<dl>
<dt><code>disk</code></dt>
<dd>The <code>disk</code> element is the main container for describing
- disks. The <code>type</code> attribute is either "file",
- "block", "dir", "network", or "volume"
- and refers to the underlying source for the disk. The optional
- <code>device</code> attribute indicates how the disk is to be exposed
- to the guest OS. Possible values for this attribute are
- "floppy", "disk", "cdrom", and "lun", defaulting to
- "disk". "lun" (<span class="since">since 0.9.10</span>) is only
- valid when type is "block" and the target element's "bus"
- attribute is "virtio", and behaves identically to "disk",
- except that generic SCSI commands from the guest are accepted
- and passed through to the physical device
- - also note that device='lun' will only be recognized for
- actual raw devices, never for individual partitions or LVM
- partitions (in those cases, the kernel will reject the generic
- SCSI commands, making it identical to device='disk').
- The optional <code>rawio</code> attribute
- (<span class="since">since 0.9.10</span>) indicates whether
- the disk is needs rawio capability; valid settings are "yes"
- or "no" (default is "no"). If any one disk in a domain has
- rawio='yes', rawio capability will be enabled for all disks in
- the domain (because, in the case of QEMU, this capability can
- only be set on a per-process basis). This attribute is only
- valid when device is "lun". NB, <code>rawio</code> intends to
- confine the capability per-device, however, current QEMU
- implementation gives the domain process broader capability
- than that (per-process basis, affects all the domain disks).
- To confine the capability as much as possible for QEMU driver
- as this stage, <code>sgio</code> is recommended, it's more
- secure than <code>rawio</code>.
- The optional <code>sgio</code> (<span class="since">since 1.0.2</span>)
- attribute indicates whether the kernel will filter unprivileged
- SG_IO commands for the disk, valid settings are "filtered" or
- "unfiltered". Defaults to "filtered". Similar to <code>rawio</code>,
- <code>sgio</code> is only valid for device 'lun'.
- The optional <code>snapshot</code> attribute indicates the default
- behavior of the disk during disk snapshots: "internal"
- requires a file format such as qcow2 that can store both the
- snapshot and the data changes since the snapshot;
- "external" will separate the snapshot from the live data; and
- "no" means the disk will not participate in snapshots.
- Read-only disks default to "no", while the default for other
- disks depends on the hypervisor's capabilities. Some
- hypervisors allow a per-snapshot choice as well,
- during <a href="formatsnapshot.html">domain snapshot
- creation</a>. Not all snapshot modes are supported;
- for example, <code>snapshot='yes'</code> with a transient disk
- generally does not make sense. <span class="since">Since 0.0.3;
- "device" attribute since 0.1.4;
- "network" attribute since 0.8.7; "snapshot" since
- 0.9.5</span></dd>
+ disks (<span class="since">since 0.0.3</span>).
+ <dl>
+ <dt><code>type</code> attribute
+ <span class="since">since 0.0.3</span></dt>
+ <dd>
+ Valid values are "file", "block",
+ "dir" (<span class="since">since 0.7.5</span>),
+ "network" (<span class="since">since 0.8.7</span>), or
+ "volume" (<span class="since">since 1.0.5</span>)
+ and refer to the underlying source for the disk.
+ </dd>
+ <dt><code>device</code> attribute
+ <span class="since">since 0.1.4</span></dt>
+ <dd>
+ Indicates how the disk is to be exposed to the guest OS. Possible
+ values for this attribute are "floppy", "disk", "cdrom", and "lun",
+ defaulting to "disk".
+ <p>
+ Using "lun" (<span class="since">since 0.9.10</span>) is only
+ valid when type is "block" and the target element's "bus"
+ attribute is "virtio", and behaves identically to "disk",
+ except that generic SCSI commands from the guest are accepted
+ and passed through to the physical device. Also note that
+ device='lun' will only be recognized for actual raw devices,
+ but never for individual partitions or LVM partitions (in those
+ cases, the kernel will reject the generic SCSI commands, making
+ it identical to device='disk').
+ </p>
+ </dd>
+ <dt><code>rawio</code> attribute
+ <span class="since">since 0.9.10</span></dt>
+ <dd>
+ Indicates whether the disk is needs rawio capability; valid
+ settings are "yes" or "no" (default is "no"). If any one disk
+ in a domain has rawio='yes', rawio capability will be enabled
+ for all disks in the domain (because, in the case of QEMU, this
+ capability can only be set on a per-process basis). This attribute
+ is only valid when device is "lun". NB, <code>rawio</code> intends
+ to confine the capability per-device, however, current QEMU
+ implementation gives the domain process broader capability
+ than that (per-process basis, affects all the domain disks).
+ To confine the capability as much as possible for QEMU driver
+ as this stage, <code>sgio</code> is recommended, it's more
+ secure than <code>rawio</code>.
+ </dd>
+ <dt><code>sgio</code> attribute
+ <span class="since">since 1.0.2</span></dt>
+ <dd>
+ Indicates whether the kernel will filter unprivileged
+ SG_IO commands for the disk, valid settings are "filtered" or
+ "unfiltered". Defaults to "filtered". Similar to <code>rawio</code>,
+ <code>sgio</code> is only valid for device 'lun'.
+ </dd>
+ <dt><code>snapshot</code> attribute
+ <span class="since">since 0.9.5</span></dt>
+ <dd>
+ Indicates the default behavior of the disk during disk snapshots:
+ "internal" requires a file format such as qcow2 that can store
+ both the snapshot and the data changes since the snapshot;
+ "external" will separate the snapshot from the live data; and
+ "no" means the disk will not participate in snapshots. Read-only
+ disks default to "no", while the default for other disks depends
+ on the hypervisor's capabilities. Some hypervisors allow a
+ per-snapshot choice as well, during
+ <a href="formatsnapshot.html">domain snapshot creation</a>.
+ Not all snapshot modes are supported; for example,
+ <code>snapshot='yes'</code> with a transient disk generally
+ does not make sense.
+ </dd>
+ </dl>
+ </dd>
<dt><code>source</code></dt>
<dd>Representation of the disk <code>source</code> depends on the
disk <code>type</code> attribute value as follows:
--
1.8.3.1
11 years, 2 months
[libvirt] [PATCH] tests: Add URI precedence checking
by Martin Kletzander
Commit a0b6a36f is fixing what commit abfff210 broke, so to avoid having
to deal with this issue again, I present you The "uriprecedencetest".
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
tests/Makefile.am | 2 ++
tests/uriprecedencetest | 77 +++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 79 insertions(+)
create mode 100755 tests/uriprecedencetest
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 09144d6..419db8b 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -98,6 +98,7 @@ EXTRA_DIST = \
storagevolxml2xmlout \
sysinfodata \
test-lib.sh \
+ uriprecedencetest \
vmx2xmldata \
xencapsdata \
xmconfigdata \
@@ -235,6 +236,7 @@ test_scripts += \
read-bufsiz \
read-non-seekable \
start \
+ uriprecedencetest \
vcpupin \
virsh-all \
virsh-optparse \
diff --git a/tests/uriprecedencetest b/tests/uriprecedencetest
new file mode 100755
index 0000000..9515e63
--- /dev/null
+++ b/tests/uriprecedencetest
@@ -0,0 +1,77 @@
+#!/bin/sh
+
+: ${srcdir=.}
+. $srcdir/test-lib.sh
+
+# This test checks if virsh obeys the proper precedence of different
+# URI settings
+test_intro "uriprecedencetest"
+
+virsh_bin="$abs_top_builddir/tools/virsh"
+counter=1
+ret=0
+
+tmpdir="$(mktemp -d)"
+cleanup_() { rm -rf "$tmpdir"; }
+
+# Create all mock files/directories to avoid permission problems
+tmphome="$tmpdir/tmp_home"
+export XDG_CONFIG_HOME="$tmpdir/.config"
+export XDG_CACHE_HOME="$tmpdir/.cache"
+export XDG_RUNTIME_HOME="XDG_CACHE_HOME"
+
+mkdir -p "$XDG_CONFIG_HOME/libvirt" "$XDG_CONFIG_HOME/virsh"
+mkdir -p "$XDG_CACHE_HOME/libvirt" "$XDG_CACHE_HOME/virsh"
+mkdir -p "$XDG_RUNTIME_HOME/libvirt" "$XDG_RUNTIME_HOME/virsh"
+
+# Main function checking for the proper uri being returned
+test_uri()
+{
+ result=0
+ if [ "$($virsh_bin uri)" != "$good_uri" ]; then
+ result=1
+ ret=1
+ fi
+ test_result "$counter" "$1" "$result"
+ counter="$((counter+1))"
+}
+
+# Precedence is the following (lowest priority first):
+#
+# 1) if run as root, 'uri_default' from /etc/libvirtd/libvirt.conf,
+# otherwise qemu:///session. There is no way to mock this file for
+# virsh/libvirt.so and the user may have set anything in there that
+# would spoil the test, so we don't test this
+#
+# 2) 'uri_default' from $XDG_CONFIG_HOME/libvirt/libvirt.conf
+#
+# 3) LIBVIRT_DEFAULT_URI
+#
+# 4) VIRSH_DEFAULT_CONNECT_URI
+#
+# 5) parameter -c (--connect)
+
+unset LIBVIRT_DEFAULT_URI
+unset VIRSH_DEFAULT_CONNECT_URI
+bad_uri="test:///default?bad_uri"
+good_uri="test:///default?good_uri"
+
+printf "uri_default=\"%s\"\n" "$good_uri" >"$XDG_CONFIG_HOME/libvirt/libvirt.conf"
+test_uri "User config file"
+
+printf "uri_default=\"%s\"\n" "$bad_uri" >"$XDG_CONFIG_HOME/libvirt/libvirt.conf"
+export LIBVIRT_DEFAULT_URI="$good_uri"
+test_uri "LIBVIRT_DEFAULT_URI"
+
+export LIBVIRT_DEFAULT_URI="$bad_uri"
+export VIRSH_DEFAULT_CONNECT_URI="$good_uri"
+test_uri "VIRSH_DEFAULT_CONNECT_URI"
+
+export VIRSH_DEFAULT_CONNECT_URI="$bad_uri"
+virsh_bin="$virsh_bin --connect $good_uri"
+test_uri "Parameter"
+
+# test_uri() increases $counter even for the last test, so we must
+# decrement it
+test_final "$((counter-1))" "$ret"
+(exit "$ret"); exit "$ret"
--
1.8.3.2
11 years, 2 months
[libvirt] [PATCH] qemuBuildNicDevStr: Add mq=on for multiqueue networking
by Michal Privoznik
If user requested multiqueue networking, beside multiple /dev/tap and
/dev/vhost-net openings, we forgot to pass mq=on onto the -device
virtio-net-pci command line. This is advised at:
http://www.linux-kvm.org/page/Multiqueue#Enable_MQ_feature
---
Notes:
Maybe worth backporting to maintainer branches too. The MQ was introduced in
the 1.0.6 release.
src/qemu/qemu_command.c | 7 ++++++-
src/qemu/qemu_command.h | 1 +
src/qemu/qemu_hotplug.c | 4 +++-
3 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index f151173..d73872a 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -4730,6 +4730,7 @@ qemuBuildNicDevStr(virDomainDefPtr def,
virDomainNetDefPtr net,
int vlan,
int bootindex,
+ bool multiqueue,
virQEMUCapsPtr qemuCaps)
{
virBuffer buf = VIR_BUFFER_INITIALIZER;
@@ -4782,6 +4783,8 @@ qemuBuildNicDevStr(virDomainDefPtr def,
virDomainVirtioEventIdxTypeToString(net->driver.virtio.event_idx));
}
}
+ if (usingVirtio && multiqueue)
+ virBufferAddLit(&buf, ",mq=on");
if (vlan == -1)
virBufferAsprintf(&buf, ",netdev=host%s", net->info.alias);
else
@@ -7275,7 +7278,9 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd,
virCommandAddArgList(cmd, "-netdev", host, NULL);
}
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
- if (!(nic = qemuBuildNicDevStr(def, net, vlan, bootindex, qemuCaps)))
+ bool multiqueue = tapfdSize > 1 || vhostfdSize > 1;
+ if (!(nic = qemuBuildNicDevStr(def, net, vlan, bootindex,
+ multiqueue, qemuCaps)))
goto cleanup;
virCommandAddArgList(cmd, "-device", nic, NULL);
} else {
diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
index 5c5c025..a9854a3 100644
--- a/src/qemu/qemu_command.h
+++ b/src/qemu/qemu_command.h
@@ -102,6 +102,7 @@ char * qemuBuildNicDevStr(virDomainDefPtr def,
virDomainNetDefPtr net,
int vlan,
int bootindex,
+ bool multiqueue,
virQEMUCapsPtr qemuCaps);
char *qemuDeviceDriveHostAlias(virDomainDiskDefPtr disk,
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 478f331..b49073b 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -859,7 +859,9 @@ int qemuDomainAttachNetDevice(virConnectPtr conn,
}
if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
- if (!(nicstr = qemuBuildNicDevStr(vm->def, net, vlan, 0, priv->qemuCaps)))
+ bool multiqueue = tapfdSize > 1 || vhostfdSize > 1;
+ if (!(nicstr = qemuBuildNicDevStr(vm->def, net, vlan, 0,
+ multiqueue, priv->qemuCaps)))
goto try_remove;
} else {
if (!(nicstr = qemuBuildNicStr(net, NULL, vlan)))
--
1.8.1.5
11 years, 2 months
[libvirt] [PATCH] LXC: mount a fresh /run directory for container
by Gao feng
The unix socket file /run/systemd/private is used to
send reboot/shutdown messages. and since this type of
unix sockets are not per net namespace , they are
global resources. systemctl in container can use
this unix socket to send shutdown message to the
systemd-shutdownd running on host. finally the
host will be poweroff.
this problem occurs when container shares the same
root directory with host.
this patch umount host's /run directory and mount
the /run directory of container as tmpfs.
Signed-off-by: Gao feng <gaofeng(a)cn.fujitsu.com>
---
src/lxc/lxc_container.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index 8abaea0..aae8e6a 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -772,6 +772,10 @@ static int lxcContainerMountBasicFS(void)
{ "sysfs", "/sys", "sysfs", NULL, MS_BIND|MS_REMOUNT|MS_RDONLY },
{ "securityfs", "/sys/kernel/security", "securityfs", NULL, MS_NOSUID|MS_NOEXEC|MS_NODEV },
{ "securityfs", "/sys/kernel/security", "securityfs", NULL, MS_BIND|MS_REMOUNT|MS_RDONLY },
+ /* We should mount /run directory as tmpfs, since it contains some
+ * global files such as /run/systemd/private which can be used to
+ * send reboot/shutdown message from container to host. */
+ { "tmpfs", "/run", "tmpfs", NULL, MS_NOSUID|MS_NOEXEC|MS_NODEV },
#if WITH_SELINUX
{ SELINUX_MOUNT, SELINUX_MOUNT, "selinuxfs", NULL, MS_NOSUID|MS_NOEXEC|MS_NODEV },
{ SELINUX_MOUNT, SELINUX_MOUNT, NULL, NULL, MS_BIND|MS_REMOUNT|MS_RDONLY },
@@ -1526,6 +1530,7 @@ static int lxcContainerSetupPivotRoot(virDomainDefPtr vmDef,
if (STREQ(root->src, "/") &&
(lxcContainerUnmountSubtree("/sys", false) < 0 ||
lxcContainerUnmountSubtree("/dev", false) < 0 ||
+ lxcContainerUnmountSubtree("/run", false) < 0 ||
lxcContainerUnmountSubtree("/proc", false) < 0))
goto cleanup;
--
1.8.3.1
11 years, 2 months
[libvirt] [PATCH]LXC: force container to enable network namespace
by Chen Hanxiao
From: Chen Hanxiao <chenhanxiao(a)cn.fujitsu.com>
If we don't enable network namespace, we could shutdown host
inside container by command 'shutdown', which is unacceptable.
This patch will force users to enable network namespace
before they start container.
Signed-off-by: Chen Hanxiao <chenhanxiao(a)cn.fujitsu.com>
---
src/lxc/lxc_container.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index c7a22ab..5631ad7 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -1937,6 +1937,12 @@ int lxcContainerStart(virDomainDefPtr def,
if (lxcNeedNetworkNamespace(def)) {
VIR_DEBUG("Enable network namespaces");
cflags |= CLONE_NEWNET;
+ } else {
+ errno = EINVAL;
+
+ virReportSystemError(errno, "%s",
+ _("Network namespace needed"));
+ return -1;
}
pid = clone(lxcContainerChild, stacktop, cflags, &args);
--
1.7.1
11 years, 2 months
[libvirt] Is it a problem that "a vm has been shutdown, but its pidfile has not been removed"
by Wangyufei (A)
Hello,
when do steps as follows:
1. start a vm
2. restart libvirtd service
3. shutdown the vm
I found the pidfile associated with the vm has not been removed.
Analyzing related piece of code, I found when libvirtd service restarted, the vm's _virDomainObj structure(named dom here) in libvirtd will be re-established according to the vm's state-file or config-file, but its member of privateData.pidfile will not be reassigned value. By the way, qemudriver is used in my libvirt.
So when the vm is shutdown, its pidfile will not be removed, because the member of privateData.pidfile is NULL.
My questions are :
1. Do you think it is a problem when a vm has been shutdown, but its pidfile has not been removed ?
2. Do you think it is expected that the member of privateData.pidfile's value missed after libvirtd restart?
If it's a bug then I'll submit the patch to fix it.
Also list the related piece of code about removing the vm's pidfile in libvirt for your information:
if (priv->pidfile &&
unlink(priv->pidfile) < 0 &&
errno != ENOENT)
VIR_WARN("Failed to remove PID file for %s: %s",
vm->def->name, virStrerror(errno, ebuf, sizeof(ebuf)));
Best Regards,
-WangYufei
11 years, 2 months
[libvirt] [PATCHv2] virBitmapParse: Fix behavior in case of error and fix up callers
by Peter Krempa
Re-arrange the code so that the returned bitmap is always initialized to
NULL even on early failures and return an error message as some callers
are already expecting it. Fix up the rest not to shadow the error.
---
Version 2:
- squashed cleanup of callers into this patch
po/POTFILES.in | 1 +
src/conf/domain_conf.c | 5 +----
src/conf/network_conf.c | 3 ---
src/nodeinfo.c | 5 +----
src/qemu/qemu_driver.c | 2 --
src/util/virbitmap.c | 18 +++++++++---------
src/xenxs/xen_sxpr.c | 5 +----
tests/cpuset | 2 +-
8 files changed, 14 insertions(+), 27 deletions(-)
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 36d027a..9a83069 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -147,6 +147,7 @@ src/util/viralloc.c
src/util/viraudit.c
src/util/virauth.c
src/util/virauthconfig.c
+src/util/virbitmap.c
src/util/vircgroup.c
src/util/virclosecallbacks.c
src/util/vircommand.c
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index ea49d2c..8a187a6 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -10981,11 +10981,8 @@ virDomainDefParseXML(xmlDocPtr xml,
tmp = virXPathString("string(./vcpu[1]/@cpuset)", ctxt);
if (tmp) {
if (virBitmapParse(tmp, 0, &def->cpumask,
- VIR_DOMAIN_CPUMASK_LEN) < 0) {
- virReportError(VIR_ERR_XML_ERROR,
- "%s", _("topology cpuset syntax error"));
+ VIR_DOMAIN_CPUMASK_LEN) < 0)
goto error;
- }
VIR_FREE(tmp);
}
}
diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index bbc980b..8aef609 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -2897,9 +2897,6 @@ virNetworkLoadState(virNetworkObjListPtr nets,
if ((class_id = virXPathString("string(./class_id[1]/@bitmap)", ctxt))) {
if (virBitmapParse(class_id, 0, &class_id_map,
CLASS_ID_BITMAP_SIZE) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Malformed 'class_id' attribute: %s"),
- class_id);
VIR_FREE(class_id);
goto error;
}
diff --git a/src/nodeinfo.c b/src/nodeinfo.c
index 4df4851..33a79b7 100644
--- a/src/nodeinfo.c
+++ b/src/nodeinfo.c
@@ -1547,11 +1547,8 @@ virNodeGetSiblingsList(const char *dir, int cpu_id)
if (virFileReadAll(path, SYSFS_THREAD_SIBLINGS_LIST_LENGTH_MAX, &buf) < 0)
goto cleanup;
- if (virBitmapParse(buf, 0, &ret, NUMA_MAX_N_CPUS) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Failed to parse thread siblings"));
+ if (virBitmapParse(buf, 0, &ret, NUMA_MAX_N_CPUS) < 0)
goto cleanup;
- }
cleanup:
VIR_FREE(buf);
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 2ad236e..5124f27 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -8357,8 +8357,6 @@ qemuDomainSetNumaParameters(virDomainPtr dom,
if (virBitmapParse(params[i].value.s,
0, &nodeset,
VIR_DOMAIN_CPUMASK_LEN) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Failed to parse nodeset"));
ret = -1;
continue;
}
diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c
index 47c678e..289a7b9 100644
--- a/src/util/virbitmap.c
+++ b/src/util/virbitmap.c
@@ -298,23 +298,21 @@ virBitmapParse(const char *str,
size_t bitmapSize)
{
bool neg = false;
- const char *cur;
+ const char *cur = str;
char *tmp;
size_t i;
int start, last;
- if (!str)
+ if (!(*bitmap = virBitmapNew(bitmapSize)))
return -1;
- cur = str;
- virSkipSpaces(&cur);
+ if (!str)
+ goto error;
- if (*cur == 0)
- return -1;
+ virSkipSpaces(&cur);
- *bitmap = virBitmapNew(bitmapSize);
- if (!*bitmap)
- return -1;
+ if (*cur == '\0')
+ goto error;
while (*cur != 0 && *cur != terminator) {
/*
@@ -384,6 +382,8 @@ virBitmapParse(const char *str,
return virBitmapCountBits(*bitmap);
error:
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Failed to parse bitmap '%s'"), str);
virBitmapFree(*bitmap);
*bitmap = NULL;
return -1;
diff --git a/src/xenxs/xen_sxpr.c b/src/xenxs/xen_sxpr.c
index fbbbaa9..6209c68 100644
--- a/src/xenxs/xen_sxpr.c
+++ b/src/xenxs/xen_sxpr.c
@@ -1160,11 +1160,8 @@ xenParseSxpr(const struct sexpr *root,
if (cpus != NULL) {
if (virBitmapParse(cpus, 0, &def->cpumask,
- VIR_DOMAIN_CPUMASK_LEN) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("invalid CPU mask %s"), cpus);
+ VIR_DOMAIN_CPUMASK_LEN) < 0)
goto error;
- }
}
def->maxvcpus = sexpr_int(root, "domain/vcpus");
diff --git a/tests/cpuset b/tests/cpuset
index b617d6f..8bcaae9 100755
--- a/tests/cpuset
+++ b/tests/cpuset
@@ -42,7 +42,7 @@ sed "s/vcpu placement='static'>/vcpu cpuset='aaa'>/" xml > xml-invalid || fail=1
$abs_top_builddir/tools/virsh --connect test:///default define xml-invalid > out 2>&1 && fail=1
cat <<\EOF > exp || fail=1
error: Failed to define domain from xml-invalid
-error: XML error: topology cpuset syntax error
+error: internal error: Failed to parse bitmap 'aaa'
EOF
compare exp out || fail=1
--
1.8.3.2
11 years, 2 months
[libvirt] [PATCH] Fix URI connect precedence
by Martin Kletzander
Commit abfff210 changed the order of vshParseArgv() and vshInit() in
order to make fix debugging of parameter parsing. However, vshInit()
did a vshReconnect() even though ctl->name wasn't set according to the
'-c' parameter yet. In order to keep both issues fixed, I've split
the vshInit() into vshInitDebug() and vshInit().
One simple memleak of ctl->name is fixed as a part of this patch,
since it is related to the issue it's fixing.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=999323
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
tools/virsh.c | 28 +++++++++++++++++-----------
1 file changed, 17 insertions(+), 11 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 15f529e..2ea44a6 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -2294,16 +2294,13 @@ vshEventLoop(void *opaque)
/*
- * Initialize connection.
+ * Initialize debug settings.
*/
-static bool
-vshInit(vshControl *ctl)
+static void
+vshInitDebug(vshControl *ctl)
{
char *debugEnv;
- if (ctl->conn)
- return false;
-
if (ctl->debug == VSH_DEBUG_DEFAULT) {
/* log level not set from commandline, check env variable */
debugEnv = getenv("VIRSH_DEBUG");
@@ -2328,6 +2325,16 @@ vshInit(vshControl *ctl)
}
vshOpenLogFile(ctl);
+}
+
+/*
+ * Initialize connection.
+ */
+static bool
+vshInit(vshControl *ctl)
+{
+ if (ctl->conn)
+ return false;
/* set up the library error handler */
virSetErrorFunc(NULL, virshErrorHandler);
@@ -3017,6 +3024,7 @@ vshParseArgv(vshControl *ctl, int argc, char **argv)
ctl->timing = true;
break;
case 'c':
+ VIR_FREE(ctl->name);
ctl->name = vshStrdup(ctl, optarg);
break;
case 'v':
@@ -3192,12 +3200,10 @@ main(int argc, char **argv)
ctl->name = vshStrdup(ctl, defaultConn);
}
- if (!vshInit(ctl)) {
- vshDeinit(ctl);
- exit(EXIT_FAILURE);
- }
+ vshInitDebug(ctl);
- if (!vshParseArgv(ctl, argc, argv)) {
+ if (!vshParseArgv(ctl, argc, argv) ||
+ !vshInit(ctl)) {
vshDeinit(ctl);
exit(EXIT_FAILURE);
}
--
1.8.3.2
11 years, 2 months
[libvirt] [PATCH 0/5] RFC: VMX parsing improvements
by Doug Goldstein
A user came into #virt the other day and was trying to get libvirtd
to work with VMWare Fusion 5, which is basically the Mac OS X version of
VMWare Workstation. In helping him out I noticed a few limitations of our
VMX parser so I've added support through this patchset. However I came
across the fact that we only support 2 types of CD-ROMs instead of the 3
types that VMWare has which leads me to believe we need to extend our
XML syntax to define VMWare VMs so I'm asking for feedback and input.
CD-ROM types:
- cdrom-image = Provides the ISO to the domain
- atapi-cdrom = Provides a NEC emulated ATAPI CD-ROM
- cdrom-raw = Passthru for a host CD-ROM drive
Currently we model 'atapi-cdrom' as (example uses IDE):
<disk type='block' device='cdrom'>
<source dev='/dev/scd0'/>
<target dev='hda' bus='ide'/>
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
</disk>
I was thinking of making that:
<disk type='block' device='cdrom'>
<driver name='vmware' type='atapi'/>
<source dev='/dev/scd0'/>
<target dev='hda' bus='ide'/>
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
</disk>
And making 'cdrom-raw' as:
<disk type='block' device='cdrom'>
<driver name='vmware' type='raw'/>
<source dev='/dev/scd0'/>
<target dev='hda' bus='ide'/>
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
</disk>
The documentation is a bit ambiguous if I should instead do:
<driver name='atapi'/>
and
<driver name='raw'/>
Which is why the request for input.
The other reason I'm asking for input is I'm not quite sure what we want to
do about CD-ROMs marked as 'auto detect', which is what VMWare Workstation
and VMWare Fusion according to their documentation use as the default for
'cdrom-raw' device type. It will either at boot time connect your CD-ROM
drive to the VM or dynamically when the user requests it. In this patchset
I've modeled it as an opened CD-ROM drive and expect that VMWare will give
us a tray closed event or CD-ROM attached event when it gets attached. I
unfortunately don't have VMWare and have not used their products in many
years so I can't test this myself.
Doug Goldstein (5):
VMX: Improve disk parse error for unknown values
VMX: Add cdrom-raw dev type from VMWare Fusion
VMX: Add support for 'auto detect' fileNames
VMX: Some serial ports are not actually connected
VMX: Add a VMWare Fusion 5 configuration for tests
src/vmx/vmx.c | 41 ++++++----
.../vmx2xml-cdrom-ide-raw-auto-detect.vmx | 5 ++
.../vmx2xml-cdrom-ide-raw-auto-detect.xml | 23 ++++++
tests/vmx2xmldata/vmx2xml-cdrom-ide-raw-device.vmx | 5 ++
tests/vmx2xmldata/vmx2xml-cdrom-ide-raw-device.xml | 24 ++++++
tests/vmx2xmldata/vmx2xml-fusion-in-the-wild-1.vmx | 88 ++++++++++++++++++++++
tests/vmx2xmldata/vmx2xml-fusion-in-the-wild-1.xml | 38 ++++++++++
tests/vmx2xmltest.c | 4 +
8 files changed, 214 insertions(+), 14 deletions(-)
create mode 100644 tests/vmx2xmldata/vmx2xml-cdrom-ide-raw-auto-detect.vmx
create mode 100644 tests/vmx2xmldata/vmx2xml-cdrom-ide-raw-auto-detect.xml
create mode 100644 tests/vmx2xmldata/vmx2xml-cdrom-ide-raw-device.vmx
create mode 100644 tests/vmx2xmldata/vmx2xml-cdrom-ide-raw-device.xml
create mode 100644 tests/vmx2xmldata/vmx2xml-fusion-in-the-wild-1.vmx
create mode 100644 tests/vmx2xmldata/vmx2xml-fusion-in-the-wild-1.xml
--
1.8.1.5
11 years, 2 months