[libvirt] [PATCH v3] qemu: Support numad
by Osier Yang
numad is an user-level daemon that monitors NUMA topology and
processes resource consumption to facilitate good NUMA resource
alignment of applications/virtual machines to improve performance
and minimize cost of remote memory latencies. It provides a
pre-placement advisory interface, so significant processes can
be pre-bound to nodes with sufficient available resources.
More details: http://fedoraproject.org/wiki/Features/numad
"numad -w ncpus:memory_amount" is the advisory interface numad
provides currently.
This patch add the support by introducing a new XML attribute
for <vcpu>. e.g.
<vcpu placement="auto">4</vcpu>
<vcpu placement="static" cpuset="1-10^6">4</vcpu>
The returned advisory nodeset from numad will be printed
in domain's dumped XML. e.g.
<vcpu placement="auto" cpuset="1-10^6">4</vcpu>
If placement is "auto", the number of vcpus and the current
memory amount specified in domain XML will be used for numad
command line (numad uses MB for memory amount):
numad -w $num_of_vcpus:$current_memory_amount / 1024
The advisory nodeset returned from numad will be used to set
domain process CPU affinity then. (e.g. qemuProcessInitCpuAffinity).
If the user specifies both CPU affinity policy (e.g.
(<vcpu cpuset="1-10,^7,^8">4</vcpu>) and placement == "auto"
the specified CPU affinity will be overridden.
Only QEMU/KVM drivers support it now.
See docs update in patch for more details.
v2 - v3:
* XML schema is changed to <vcpu placement="static|auto">4</vcpu>
* Affected tests are updated
* LXC driver's support is dropped, let's see what's the real
performance on qemu driver first.
v1 - v2:
* Since Bill Gray says it doesn't matter to use the number of
vcpus and current memory amount as numad cmd line argument,
though from sementics point of view, what numad expects are
physical CPU numbers, let's go this way.
v2 dropped XML <cpu required_cpu='4' required_memory='512000'/>,
and just a new boolean XML element <autonuma>. Codes are refactored
accordingly.
* v1 overrides the cpuset specified by <vcpu cpuset='1-10,^7'>2</vcpu>,
v2 doesn't do that, but just silently ignored.
* xml2xml test is added
---
configure.ac | 8 ++
docs/formatdomain.html.in | 17 +++-
docs/schemas/domaincommon.rng | 8 ++
src/conf/domain_conf.c | 119 ++++++++++++++------
src/conf/domain_conf.h | 10 ++
src/libvirt_private.syms | 2 +
src/qemu/qemu_process.c | 96 ++++++++++++++--
tests/domainsnapshotxml2xmlout/disk_snapshot.xml | 2 +-
tests/domainsnapshotxml2xmlout/full_domain.xml | 2 +-
tests/domainsnapshotxml2xmlout/metadata.xml | 2 +-
.../qemuxml2argv-channel-guestfwd.xml | 2 +-
.../qemuxml2argv-channel-spicevmc-old.xml | 2 +-
.../qemuxml2argv-channel-spicevmc.xml | 2 +-
.../qemuxml2argv-channel-virtio-auto.xml | 2 +-
.../qemuxml2argv-channel-virtio.xml | 2 +-
.../qemuxml2argv-console-virtio-many.xml | 2 +-
.../qemuxml2argv-console-virtio.xml | 2 +-
tests/qemuxml2argvdata/qemuxml2argv-metadata.xml | 2 +-
tests/qemuxml2argvdata/qemuxml2argv-minimal.xml | 2 +-
.../qemuxml2argv-seclabel-dynamic-baselabel.xml | 2 +-
.../qemuxml2argv-seclabel-dynamic-override.xml | 2 +-
.../qemuxml2argv-seclabel-dynamic.xml | 2 +-
.../qemuxml2argv-seclabel-none.xml | 2 +-
.../qemuxml2argv-seclabel-static-relabel.xml | 2 +-
.../qemuxml2argv-seclabel-static.xml | 2 +-
.../qemuxml2xmlout-channel-virtio-auto.xml | 2 +-
.../qemuxml2xmlout-console-virtio.xml | 2 +-
.../qemuxml2xmloutdata/qemuxml2xmlout-metadata.xml | 2 +-
28 files changed, 232 insertions(+), 70 deletions(-)
diff --git a/configure.ac b/configure.ac
index c9cdd7b..31f0835 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1445,6 +1445,14 @@ AM_CONDITIONAL([HAVE_NUMACTL], [test "$with_numactl" != "no"])
AC_SUBST([NUMACTL_CFLAGS])
AC_SUBST([NUMACTL_LIBS])
+dnl Do we have numad?
+if test "$with_qemu" = "yes"; then
+ AC_PATH_PROG([NUMAD], [numad], [], [/bin:/usr/bin:/usr/local/bin:$PATH])
+
+ if test -n "$NUMAD"; then
+ AC_DEFINE_UNQUOTED([NUMAD],["$NUMAD"], [Location or name of the numad program])
+ fi
+fi
dnl pcap lib
LIBPCAP_CONFIG="pcap-config"
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 7710c5b..ad7f591 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -318,7 +318,7 @@
<pre>
<domain>
...
- <vcpu cpuset="1-4,^3,6" current="1">2</vcpu>
+ <vcpu placement='static' cpuset="1-4,^3,6" current="1">2</vcpu>
...
</domain>
</pre>
@@ -336,7 +336,18 @@
be excluded from a previous range. <span class="since">Since
0.8.5</span>, the optional attribute <code>current</code> can
be used to specify whether fewer than the maximum number of
- virtual CPUs should be enabled.
+ virtual CPUs should be enabled. <span class="since">Since
+ 0.9.11 (QEMU and KVM only), the optional attribute
+ <code>placement</code> can be used to indicate the CPU placement
+ mode for domain process, its value can be either "static" or
+ "auto", defaults to "static" if <code>cpuset</code> is specified,
+ "auto" indicates the domain process will be pinned to the advisory
+ nodeset from querying numad, and the value of attribute
+ <code>cpuset</code> will be overridden by the advisory nodeset
+ from numad if it's specified. If both <code>cpuset</code> and
+ <code>placement</code> are not specified, or if <code>placement</code>
+ is "static", but no <code>cpuset</code> is specified, the domain
+ process will be pinned to all the available physical CPUs.
</dd>
</dl>
@@ -544,7 +555,7 @@
<span class='since'>Since 0.9.3</span>
<dt><code>memory</code></dt>
<dd>
- The optional <code>memory</code> element specify how to allocate memory
+ The optional <code>memory</code> element specifies how to allocate memory
for the domain process on a NUMA host. It contains two attributes,
attribute <code>mode</code> is either 'interleave', 'strict',
or 'preferred',
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 073ad37..451a629 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -488,6 +488,14 @@
<optional>
<element name="vcpu">
<optional>
+ <attribute name="placement">
+ <choice>
+ <value>static</value>
+ <value>auto</value>
+ </choice>
+ </attribute>
+ </optional>
+ <optional>
<attribute name="cpuset">
<ref name="cpuset"/>
</attribute>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 601dc8b..353469d 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -618,6 +618,11 @@ VIR_ENUM_IMPL(virDomainStartupPolicy, VIR_DOMAIN_STARTUP_POLICY_LAST,
"requisite",
"optional");
+VIR_ENUM_IMPL(virDomainCpuPlacementMode, VIR_DOMAIN_CPU_PLACEMENT_MODE_LAST,
+ "default",
+ "static",
+ "auto");
+
#define virDomainReportError(code, ...) \
virReportErrorHelper(VIR_FROM_DOMAIN, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
@@ -7447,7 +7452,6 @@ error:
goto cleanup;
}
-
static int virDomainDefMaybeAddController(virDomainDefPtr def,
int type,
int idx)
@@ -7561,6 +7565,7 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
bool uuid_generated = false;
virBitmapPtr bootMap = NULL;
unsigned long bootMapSize = 0;
+ xmlNodePtr cur;
if (VIR_ALLOC(def) < 0) {
virReportOOMError();
@@ -7789,6 +7794,22 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
VIR_FREE(tmp);
}
+ tmp = virXPathString("string(./vcpu[1]/@placement)", ctxt);
+ if (tmp) {
+ if ((def->placement_mode =
+ virDomainCpuPlacementModeTypeFromString(tmp)) < 0) {
+ virDomainReportError(VIR_ERR_XML_ERROR,
+ _("Unsupported CPU placement mode '%s'"),
+ tmp);
+ VIR_FREE(tmp);
+ goto error;
+ }
+ VIR_FREE(tmp);
+ } else {
+ if (def->cpumasklen)
+ def->placement_mode = VIR_DOMAIN_CPU_PLACEMENT_MODE_STATIC;
+ }
+
/* Extract cpu tunables. */
if (virXPathULong("string(./cputune/shares[1])", ctxt,
&def->cputune.shares) < 0)
@@ -7836,47 +7857,74 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
VIR_FREE(nodes);
/* Extract numatune if exists. */
- if ((n = virXPathNodeSet("./numatune", ctxt, NULL)) < 0) {
+ if ((n = virXPathNodeSet("./numatune", ctxt, &nodes)) < 0) {
virDomainReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("cannot extract numatune nodes"));
goto error;
}
+ if (n > 1) {
+ virDomainReportError(VIR_ERR_XML_ERROR, "%s",
+ _("only one numatune is supported"));
+ VIR_FREE(nodes);
+ goto error;
+ }
+
if (n) {
- tmp = virXPathString("string(./numatune/memory/@nodeset)", ctxt);
- if (tmp) {
- char *set = tmp;
- int nodemasklen = VIR_DOMAIN_CPUMASK_LEN;
+ cur = nodes[0]->children;
+ while (cur != NULL) {
+ if (cur->type == XML_ELEMENT_NODE) {
+ if ((xmlStrEqual(cur->name, BAD_CAST "memory"))) {
+ tmp = virXMLPropString(cur, "nodeset");
- if (VIR_ALLOC_N(def->numatune.memory.nodemask, nodemasklen) < 0) {
- goto no_memory;
- }
+ if (tmp) {
+ char *set = tmp;
+ int nodemasklen = VIR_DOMAIN_CPUMASK_LEN;
- /* "nodeset" leads same syntax with "cpuset". */
- if (virDomainCpuSetParse(set, 0, def->numatune.memory.nodemask,
- nodemasklen) < 0)
- goto error;
- VIR_FREE(tmp);
- } else {
- virDomainReportError(VIR_ERR_INTERNAL_ERROR,
- "%s", _("nodeset for NUMA memory tuning must be set"));
- goto error;
- }
+ if (VIR_ALLOC_N(def->numatune.memory.nodemask,
+ nodemasklen) < 0) {
+ virReportOOMError();
+ goto error;
+ }
- tmp = virXPathString("string(./numatune/memory/@mode)", ctxt);
- if (tmp) {
- if ((def->numatune.memory.mode =
- virDomainNumatuneMemModeTypeFromString(tmp)) < 0) {
- virDomainReportError(VIR_ERR_INTERNAL_ERROR,
- _("Unsupported NUMA memory tuning mode '%s'"),
- tmp);
- goto error;
+ /* "nodeset" leads same syntax with "cpuset". */
+ if (virDomainCpuSetParse(set, 0,
+ def->numatune.memory.nodemask,
+ nodemasklen) < 0)
+ goto error;
+ VIR_FREE(tmp);
+ } else {
+ virDomainReportError(VIR_ERR_XML_ERROR, "%s",
+ _("nodeset for NUMA memory "
+ "tuning must be set"));
+ goto error;
+ }
+
+ tmp = virXMLPropString(cur, "mode");
+ if (tmp) {
+ if ((def->numatune.memory.mode =
+ virDomainNumatuneMemModeTypeFromString(tmp)) < 0) {
+ virDomainReportError(VIR_ERR_XML_ERROR,
+ _("Unsupported NUMA memory "
+ "tuning mode '%s'"),
+ tmp);
+ goto error;
+ }
+ VIR_FREE(tmp);
+ } else {
+ def->numatune.memory.mode = VIR_DOMAIN_NUMATUNE_MEM_STRICT;
+ }
+ } else {
+ virDomainReportError(VIR_ERR_XML_ERROR,
+ _("unsupported XML element %s"),
+ (const char *)cur->name);
+ goto error;
+ }
}
- VIR_FREE(tmp);
- } else {
- def->numatune.memory.mode = VIR_DOMAIN_NUMATUNE_MEM_STRICT;
+ cur = cur->next;
}
}
+ VIR_FREE(nodes);
n = virXPathNodeSet("./features/*", ctxt, &nodes);
if (n < 0)
@@ -12160,6 +12208,9 @@ virDomainDefFormatInternal(virDomainDefPtr def,
allones = 0;
virBufferAddLit(buf, " <vcpu");
+ if (def->placement_mode)
+ virBufferAsprintf(buf, " placement='%s'",
+ virDomainCpuPlacementModeTypeToString(def->placement_mode));
if (!allones) {
char *cpumask = NULL;
if ((cpumask =
@@ -12211,22 +12262,24 @@ virDomainDefFormatInternal(virDomainDefPtr def,
virBufferAddLit(buf, " </cputune>\n");
if (def->numatune.memory.nodemask) {
+ virBufferAddLit(buf, " <numatune>\n");
const char *mode;
char *nodemask = NULL;
- virBufferAddLit(buf, " <numatune>\n");
nodemask = virDomainCpuSetFormat(def->numatune.memory.nodemask,
VIR_DOMAIN_CPUMASK_LEN);
if (nodemask == NULL) {
virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("failed to format nodeset for NUMA memory tuning"));
+ _("failed to format nodeset for "
+ "NUMA memory tuning"));
goto cleanup;
}
mode = virDomainNumatuneMemModeTypeToString(def->numatune.memory.mode);
virBufferAsprintf(buf, " <memory mode='%s' nodeset='%s'/>\n",
- mode, nodemask);
+ mode, nodemask);
VIR_FREE(nodemask);
+
virBufferAddLit(buf, " </numatune>\n");
}
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 23c1947..4914d69 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1380,6 +1380,14 @@ enum virDomainTimerModeType {
VIR_DOMAIN_TIMER_MODE_LAST,
};
+enum virDomainCpuPlacementMode {
+ VIR_DOMAIN_CPU_PLACEMENT_MODE_DEFAULT = 0,
+ VIR_DOMAIN_CPU_PLACEMENT_MODE_STATIC,
+ VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO,
+
+ VIR_DOMAIN_CPU_PLACEMENT_MODE_LAST,
+};
+
typedef struct _virDomainTimerCatchupDef virDomainTimerCatchupDef;
typedef virDomainTimerCatchupDef *virDomainTimerCatchupDefPtr;
struct _virDomainTimerCatchupDef {
@@ -1506,6 +1514,7 @@ struct _virDomainDef {
} mem;
unsigned short vcpus;
unsigned short maxvcpus;
+ int placement_mode;
int cpumasklen;
char *cpumask;
@@ -2135,6 +2144,7 @@ VIR_ENUM_DECL(virDomainTimerName)
VIR_ENUM_DECL(virDomainTimerTrack)
VIR_ENUM_DECL(virDomainTimerTickpolicy)
VIR_ENUM_DECL(virDomainTimerMode)
+VIR_ENUM_DECL(virDomainCpuPlacementMode)
VIR_ENUM_DECL(virDomainStartupPolicy)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 1439d3b..68f5c94 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -270,6 +270,8 @@ virDomainControllerModelSCSITypeToString;
virDomainControllerModelUSBTypeFromString;
virDomainControllerModelUSBTypeToString;
virDomainControllerTypeToString;
+virDomainCpuPlacementTypeFromString;
+virDomainCpuPlacementTypeToString;
virDomainCpuSetFormat;
virDomainCpuSetParse;
virDomainDefAddImplicitControllers;
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index bea354b..6ba4713 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -1633,11 +1633,47 @@ qemuProcessInitNumaMemoryPolicy(virDomainObjPtr vm)
}
#endif
+#if defined(NUMAD)
+static char *
+qemuGetNumadAdvice(virDomainDefPtr def)
+{
+ virCommandPtr cmd = NULL;
+ char *args = NULL;
+ char *output = NULL;
+
+ if (virAsprintf(&args, "%d:%lu", def->vcpus, def->mem.cur_balloon) < 0) {
+ virReportOOMError();
+ goto out;
+ }
+ cmd = virCommandNewArgList(NUMAD, "-w", args, NULL);
+
+ virCommandSetOutputBuffer(cmd, &output);
+
+ if (virCommandRun(cmd, NULL) < 0)
+ qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Failed to query numad for the advisory nodeset"));
+
+out:
+ VIR_FREE(args);
+ virCommandFree(cmd);
+ return output;
+}
+#else
+static char *
+qemuGetNumadAdvice(virDomainDefPtr def ATTRIBUTE_UNUSED)
+{
+ qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("numad is not available on this host"));
+ return NULL;
+}
+#endif
+
/*
* To be run between fork/exec of QEMU only
*/
static int
-qemuProcessInitCpuAffinity(virDomainObjPtr vm)
+qemuProcessInitCpuAffinity(struct qemud_driver *driver,
+ virDomainObjPtr vm)
{
int i, hostcpus, maxcpu = QEMUD_CPUMASK_LEN;
virNodeInfo nodeinfo;
@@ -1661,19 +1697,53 @@ qemuProcessInitCpuAffinity(virDomainObjPtr vm)
return -1;
}
- if (vm->def->cpumask) {
- /* XXX why don't we keep 'cpumask' in the libvirt cpumap
- * format to start with ?!?! */
- for (i = 0 ; i < maxcpu && i < vm->def->cpumasklen ; i++)
- if (vm->def->cpumask[i])
+ if (vm->def->placement_mode == VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO) {
+ char *tmp_cpumask = NULL;
+ char *nodeset = NULL;
+
+ nodeset = qemuGetNumadAdvice(vm->def);
+ if (!nodeset)
+ return -1;
+
+ if (VIR_ALLOC_N(tmp_cpumask, VIR_DOMAIN_CPUMASK_LEN) < 0) {
+ virReportOOMError();
+ return -1;
+ }
+
+ if (virDomainCpuSetParse(nodeset, 0, tmp_cpumask,
+ VIR_DOMAIN_CPUMASK_LEN) < 0) {
+ VIR_FREE(tmp_cpumask);
+ VIR_FREE(nodeset);
+ return -1;
+ }
+
+ for (i = 0; i < maxcpu && i < VIR_DOMAIN_CPUMASK_LEN; i++) {
+ if (tmp_cpumask[i])
VIR_USE_CPU(cpumap, i);
+ }
+
+ VIR_FREE(vm->def->cpumask);
+ vm->def->cpumask = tmp_cpumask;
+ if (virDomainSaveStatus(driver->caps, driver->stateDir, vm) < 0) {
+ VIR_WARN("Unable to save status on vm %s after state change",
+ vm->def->name);
+ }
+ VIR_FREE(nodeset);
} else {
- /* You may think this is redundant, but we can't assume libvirtd
- * itself is running on all pCPUs, so we need to explicitly set
- * the spawned QEMU instance to all pCPUs if no map is given in
- * its config file */
- for (i = 0 ; i < maxcpu ; i++)
- VIR_USE_CPU(cpumap, i);
+ if (vm->def->cpumask) {
+ /* XXX why don't we keep 'cpumask' in the libvirt cpumap
+ * format to start with ?!?! */
+ for (i = 0 ; i < maxcpu && i < vm->def->cpumasklen ; i++)
+ if (vm->def->cpumask[i])
+ VIR_USE_CPU(cpumap, i);
+ } else {
+ /* You may think this is redundant, but we can't assume libvirtd
+ * itself is running on all pCPUs, so we need to explicitly set
+ * the spawned QEMU instance to all pCPUs if no map is given in
+ * its config file */
+ for (i = 0 ; i < maxcpu ; i++)
+ VIR_USE_CPU(cpumap, i);
+ }
}
/* We are pressuming we are running between fork/exec of QEMU
@@ -2404,7 +2474,7 @@ static int qemuProcessHook(void *data)
/* This must be done after cgroup placement to avoid resetting CPU
* affinity */
VIR_DEBUG("Setup CPU affinity");
- if (qemuProcessInitCpuAffinity(h->vm) < 0)
+ if (qemuProcessInitCpuAffinity(h->driver, h->vm) < 0)
goto cleanup;
if (qemuProcessInitNumaMemoryPolicy(h->vm) < 0)
diff --git a/tests/domainsnapshotxml2xmlout/disk_snapshot.xml b/tests/domainsnapshotxml2xmlout/disk_snapshot.xml
index 29f60be..0a4b179 100644
--- a/tests/domainsnapshotxml2xmlout/disk_snapshot.xml
+++ b/tests/domainsnapshotxml2xmlout/disk_snapshot.xml
@@ -28,7 +28,7 @@
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
<memory unit='KiB'>219100</memory>
<currentMemory unit='KiB'>219100</currentMemory>
- <vcpu cpuset='1-4,8-20,525'>1</vcpu>
+ <vcpu placement='static' cpuset='1-4,8-20,525'>1</vcpu>
<os>
<type arch='i686' machine='pc'>hvm</type>
<boot dev='hd'/>
diff --git a/tests/domainsnapshotxml2xmlout/full_domain.xml b/tests/domainsnapshotxml2xmlout/full_domain.xml
index f77d6b0..27cf41d 100644
--- a/tests/domainsnapshotxml2xmlout/full_domain.xml
+++ b/tests/domainsnapshotxml2xmlout/full_domain.xml
@@ -11,7 +11,7 @@
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
<memory unit='KiB'>219100</memory>
<currentMemory unit='KiB'>219100</currentMemory>
- <vcpu cpuset='1-4,8-20,525'>1</vcpu>
+ <vcpu placement='static' cpuset='1-4,8-20,525'>1</vcpu>
<os>
<type arch='i686' machine='pc'>hvm</type>
<boot dev='hd'/>
diff --git a/tests/domainsnapshotxml2xmlout/metadata.xml b/tests/domainsnapshotxml2xmlout/metadata.xml
index 1a27773..93c9f39 100644
--- a/tests/domainsnapshotxml2xmlout/metadata.xml
+++ b/tests/domainsnapshotxml2xmlout/metadata.xml
@@ -15,7 +15,7 @@
</metadata>
<memory unit='KiB'>219100</memory>
<currentMemory unit='KiB'>219100</currentMemory>
- <vcpu cpuset='1-4,8-20,525'>1</vcpu>
+ <vcpu placement='static' cpuset='1-4,8-20,525'>1</vcpu>
<os>
<type arch='i686' machine='pc'>hvm</type>
<boot dev='hd'/>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-channel-guestfwd.xml b/tests/qemuxml2argvdata/qemuxml2argv-channel-guestfwd.xml
index 7de7245..60e853c 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-channel-guestfwd.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-channel-guestfwd.xml
@@ -3,7 +3,7 @@
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
<memory unit='KiB'>219100</memory>
<currentMemory unit='KiB'>219100</currentMemory>
- <vcpu cpuset='1-4,8-20,525'>1</vcpu>
+ <vcpu placement='static' cpuset='1-4,8-20,525'>1</vcpu>
<os>
<type arch='i686' machine='pc'>hvm</type>
<boot dev='hd'/>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-channel-spicevmc-old.xml b/tests/qemuxml2argvdata/qemuxml2argv-channel-spicevmc-old.xml
index e4945e9..3269793 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-channel-spicevmc-old.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-channel-spicevmc-old.xml
@@ -2,7 +2,7 @@
<name>QEMUGuest1</name>
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
<memory unit='KiB'>219136</memory>
- <vcpu cpuset='1-4,8-20,525'>1</vcpu>
+ <vcpu placement='static' cpuset='1-4,8-20,525'>1</vcpu>
<os>
<type arch='i686' machine='pc'>hvm</type>
<boot dev='hd'/>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-channel-spicevmc.xml b/tests/qemuxml2argvdata/qemuxml2argv-channel-spicevmc.xml
index e4945e9..3269793 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-channel-spicevmc.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-channel-spicevmc.xml
@@ -2,7 +2,7 @@
<name>QEMUGuest1</name>
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
<memory unit='KiB'>219136</memory>
- <vcpu cpuset='1-4,8-20,525'>1</vcpu>
+ <vcpu placement='static' cpuset='1-4,8-20,525'>1</vcpu>
<os>
<type arch='i686' machine='pc'>hvm</type>
<boot dev='hd'/>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-channel-virtio-auto.xml b/tests/qemuxml2argvdata/qemuxml2argv-channel-virtio-auto.xml
index 91a973a..a94084c 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-channel-virtio-auto.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-channel-virtio-auto.xml
@@ -3,7 +3,7 @@
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
<memory unit='KiB'>219100</memory>
<currentMemory unit='KiB'>219100</currentMemory>
- <vcpu cpuset='1-4,8-20,525'>1</vcpu>
+ <vcpu placement='static' cpuset='1-4,8-20,525'>1</vcpu>
<os>
<type arch='i686' machine='pc'>hvm</type>
<boot dev='hd'/>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-channel-virtio.xml b/tests/qemuxml2argvdata/qemuxml2argv-channel-virtio.xml
index 960442a..a280842 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-channel-virtio.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-channel-virtio.xml
@@ -3,7 +3,7 @@
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
<memory unit='KiB'>219100</memory>
<currentMemory unit='KiB'>219100</currentMemory>
- <vcpu cpuset='1-4,8-20,525'>1</vcpu>
+ <vcpu placement='static' cpuset='1-4,8-20,525'>1</vcpu>
<os>
<type arch='i686' machine='pc'>hvm</type>
<boot dev='hd'/>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-console-virtio-many.xml b/tests/qemuxml2argvdata/qemuxml2argv-console-virtio-many.xml
index 626250c..6028a2c 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-console-virtio-many.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-console-virtio-many.xml
@@ -3,7 +3,7 @@
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
<memory unit='KiB'>219100</memory>
<currentMemory unit='KiB'>219100</currentMemory>
- <vcpu cpuset='1-4,8-20,525'>1</vcpu>
+ <vcpu placement='static' cpuset='1-4,8-20,525'>1</vcpu>
<os>
<type arch='i686' machine='pc'>hvm</type>
<boot dev='hd'/>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-console-virtio.xml b/tests/qemuxml2argvdata/qemuxml2argv-console-virtio.xml
index 0eb026e..812e5dd 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-console-virtio.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-console-virtio.xml
@@ -3,7 +3,7 @@
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
<memory unit='KiB'>219100</memory>
<currentMemory unit='KiB'>219100</currentMemory>
- <vcpu cpuset='1-4,8-20,525'>1</vcpu>
+ <vcpu placement='static' cpuset='1-4,8-20,525'>1</vcpu>
<os>
<type arch='i686' machine='pc'>hvm</type>
<boot dev='hd'/>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-metadata.xml b/tests/qemuxml2argvdata/qemuxml2argv-metadata.xml
index e3c2b10..c741f0d 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-metadata.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-metadata.xml
@@ -3,7 +3,7 @@
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
<memory unit='KiB'>219100</memory>
<currentMemory unit='KiB'>219100</currentMemory>
- <vcpu cpuset='1-4,8-20,525'>1</vcpu>
+ <vcpu placement='static' cpuset='1-4,8-20,525'>1</vcpu>
<os>
<type arch='i686' machine='pc'>hvm</type>
<boot dev='hd'/>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-minimal.xml b/tests/qemuxml2argvdata/qemuxml2argv-minimal.xml
index 26790b1..26fdf0d 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-minimal.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-minimal.xml
@@ -8,7 +8,7 @@
</description>
<memory unit='KiB'>219100</memory>
<currentMemory unit='KiB'>219100</currentMemory>
- <vcpu cpuset='1-4,8-20,525'>1</vcpu>
+ <vcpu placement='static' cpuset='1-4,8-20,525'>1</vcpu>
<os>
<type arch='i686' machine='pc'>hvm</type>
<boot dev='hd'/>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-seclabel-dynamic-baselabel.xml b/tests/qemuxml2argvdata/qemuxml2argv-seclabel-dynamic-baselabel.xml
index f27dc2e..98362a7 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-seclabel-dynamic-baselabel.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-seclabel-dynamic-baselabel.xml
@@ -3,7 +3,7 @@
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
<memory unit='KiB'>219100</memory>
<currentMemory unit='KiB'>219100</currentMemory>
- <vcpu cpuset='1-4,8-20,525'>1</vcpu>
+ <vcpu placement='static' cpuset='1-4,8-20,525'>1</vcpu>
<os>
<type arch='i686' machine='pc'>hvm</type>
<boot dev='hd'/>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-seclabel-dynamic-override.xml b/tests/qemuxml2argvdata/qemuxml2argv-seclabel-dynamic-override.xml
index 233501f..4de435b 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-seclabel-dynamic-override.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-seclabel-dynamic-override.xml
@@ -3,7 +3,7 @@
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
<memory unit='KiB'>219100</memory>
<currentMemory unit='KiB'>219100</currentMemory>
- <vcpu cpuset='1-4,8-20,525'>1</vcpu>
+ <vcpu placement='static' cpuset='1-4,8-20,525'>1</vcpu>
<os>
<type arch='i686' machine='pc'>hvm</type>
<boot dev='hd'/>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-seclabel-dynamic.xml b/tests/qemuxml2argvdata/qemuxml2argv-seclabel-dynamic.xml
index d9fa37c..78a6b6a 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-seclabel-dynamic.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-seclabel-dynamic.xml
@@ -3,7 +3,7 @@
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
<memory unit='KiB'>219100</memory>
<currentMemory unit='KiB'>219100</currentMemory>
- <vcpu cpuset='1-4,8-20,525'>1</vcpu>
+ <vcpu placement='static' cpuset='1-4,8-20,525'>1</vcpu>
<os>
<type arch='i686' machine='pc'>hvm</type>
<boot dev='hd'/>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-seclabel-none.xml b/tests/qemuxml2argvdata/qemuxml2argv-seclabel-none.xml
index ec8e8c7..1a6878c 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-seclabel-none.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-seclabel-none.xml
@@ -3,7 +3,7 @@
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
<memory unit='KiB'>219100</memory>
<currentMemory unit='KiB'>219100</currentMemory>
- <vcpu cpuset='1-4,8-20,525'>1</vcpu>
+ <vcpu placement='static' cpuset='1-4,8-20,525'>1</vcpu>
<os>
<type arch='i686' machine='pc'>hvm</type>
<boot dev='hd'/>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-seclabel-static-relabel.xml b/tests/qemuxml2argvdata/qemuxml2argv-seclabel-static-relabel.xml
index d1ea841..70f9e11 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-seclabel-static-relabel.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-seclabel-static-relabel.xml
@@ -3,7 +3,7 @@
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
<memory unit='KiB'>219100</memory>
<currentMemory unit='KiB'>219100</currentMemory>
- <vcpu cpuset='1-4,8-20,525'>1</vcpu>
+ <vcpu placement='static' cpuset='1-4,8-20,525'>1</vcpu>
<os>
<type arch='i686' machine='pc'>hvm</type>
<boot dev='hd'/>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-seclabel-static.xml b/tests/qemuxml2argvdata/qemuxml2argv-seclabel-static.xml
index a792d9b..31d5f58 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-seclabel-static.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-seclabel-static.xml
@@ -3,7 +3,7 @@
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
<memory unit='KiB'>219100</memory>
<currentMemory unit='KiB'>219100</currentMemory>
- <vcpu cpuset='1-4,8-20,525'>1</vcpu>
+ <vcpu placement='static' cpuset='1-4,8-20,525'>1</vcpu>
<os>
<type arch='i686' machine='pc'>hvm</type>
<boot dev='hd'/>
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-channel-virtio-auto.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-channel-virtio-auto.xml
index cb345aa..c257292 100644
--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-channel-virtio-auto.xml
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-channel-virtio-auto.xml
@@ -3,7 +3,7 @@
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
<memory unit='KiB'>219100</memory>
<currentMemory unit='KiB'>219100</currentMemory>
- <vcpu cpuset='1-4,8-20,525'>1</vcpu>
+ <vcpu placement='static' cpuset='1-4,8-20,525'>1</vcpu>
<os>
<type arch='i686' machine='pc'>hvm</type>
<boot dev='hd'/>
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-virtio.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-virtio.xml
index 93255a9..031f821 100644
--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-virtio.xml
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-console-virtio.xml
@@ -3,7 +3,7 @@
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
<memory unit='KiB'>219100</memory>
<currentMemory unit='KiB'>219100</currentMemory>
- <vcpu cpuset='1-4,8-20,525'>1</vcpu>
+ <vcpu placement='static' cpuset='1-4,8-20,525'>1</vcpu>
<os>
<type arch='i686' machine='pc'>hvm</type>
<boot dev='hd'/>
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-metadata.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-metadata.xml
index 772ad17..c3a55cf 100644
--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-metadata.xml
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-metadata.xml
@@ -7,7 +7,7 @@
</metadata>
<memory unit='KiB'>219100</memory>
<currentMemory unit='KiB'>219100</currentMemory>
- <vcpu cpuset='1-4,8-20,525'>1</vcpu>
+ <vcpu placement='static' cpuset='1-4,8-20,525'>1</vcpu>
<os>
<type arch='i686' machine='pc'>hvm</type>
<boot dev='hd'/>
--
1.7.1
12 years, 8 months
[libvirt] [PATCH v2 0/3] Use guest agent to quiesce disks
by Michal Privoznik
Since we have qemu guest agent support in libvirt,
we can start wiring up some things that GA already
knows how to do. One of them is file system freeze
and thaw. Domain snapshots can profit from this
functionality.
Michal Privoznik (3):
qemu_agent: Create file system freeze and thaw functions
snapshots: Introduce VIR_DOMAIN_SNAPSHOT_CREATE_QUIESCE flag
virsh: Expose new VIR_DOMAIN_SNAPSHOT_CREATE_QUIESCE flag
include/libvirt/libvirt.h.in | 4 ++
src/libvirt.c | 6 +++
src/qemu/qemu_agent.c | 74 +++++++++++++++++++++++++++++++++++
src/qemu/qemu_agent.h | 3 +
src/qemu/qemu_driver.c | 87 ++++++++++++++++++++++++++++++++++++++----
tools/virsh.c | 6 +++
tools/virsh.pod | 16 +++++++-
7 files changed, 186 insertions(+), 10 deletions(-)
--
1.7.3.4
12 years, 8 months
[libvirt] [PATCH] Add support for forcing a private network namespace for LXC guests
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
If no <interface> elements are included in an LXC guest XML
description, then the LXC guest will just see the host's
network interfaces. It is desirable to be able to hide the
host interfaces, without having to define any guest interfaces.
This patch introduces a new feature flag <privnet/> to allow
forcing of a private network namespace for LXC. In the future
I also anticipate that we will add <privuser/> to force a
private user ID namespace.
* src/conf/domain_conf.c, src/conf/domain_conf.h: Add support
for <privnet/> feature. Auto-set <privnet> if any <interface>
devices are defined
* src/lxc/lxc_container.c: Honour request for private network
namespace
NB: this was ACKed way back in January, but I forgot to push
it then. Pushing it now - this re-post is just to remind folks
where it came from
https://www.redhat.com/archives/libvir-list/2012-January/msg01018.html
---
docs/formatdomain.html.in | 7 +++++++
docs/schemas/domaincommon.rng | 5 +++++
src/conf/domain_conf.c | 3 ++-
src/conf/domain_conf.h | 1 +
src/lxc/lxc_container.c | 12 ++++++++----
5 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 624c6b2..4edada3 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -897,6 +897,7 @@
<acpi/>
<apic/>
<hap/>
+ <privnet/>
</features>
...</pre>
@@ -924,6 +925,12 @@
<dd>Enable Viridian hypervisor extensions for paravirtualizing
guest operating systems
</dd>
+ <dt><code>privnet</code></dt>
+ <dd>Always create a private network namespace. This is
+ automatically set if any interface devices are defined.
+ This feature is only relevant for container based
+ virtualization drivers, such as LXC.
+ </dd>
</dl>
<h3><a name="elementsTime">Time keeping</a></h3>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index b804a70..5b3e5fa 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -2632,6 +2632,11 @@
<empty/>
</element>
</optional>
+ <optional>
+ <element name="privnet">
+ <empty/>
+ </element>
+ </optional>
</interleave>
</element>
</optional>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index f6f8b8c..e6d0f4b 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -106,7 +106,8 @@ VIR_ENUM_IMPL(virDomainFeature, VIR_DOMAIN_FEATURE_LAST,
"apic",
"pae",
"hap",
- "viridian")
+ "viridian",
+ "privnet")
VIR_ENUM_IMPL(virDomainLifecycle, VIR_DOMAIN_LIFECYCLE_LAST,
"destroy",
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 0ab3b81..f471e35 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1298,6 +1298,7 @@ enum virDomainFeature {
VIR_DOMAIN_FEATURE_PAE,
VIR_DOMAIN_FEATURE_HAP,
VIR_DOMAIN_FEATURE_VIRIDIAN,
+ VIR_DOMAIN_FEATURE_PRIVNET,
VIR_DOMAIN_FEATURE_LAST
};
diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index d827b35..267fbfb 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -261,7 +261,8 @@ int lxcContainerWaitForContinue(int control)
*
* Returns 0 on success or nonzero in case of error
*/
-static int lxcContainerRenameAndEnableInterfaces(unsigned int nveths,
+static int lxcContainerRenameAndEnableInterfaces(bool privNet,
+ unsigned int nveths,
char **veths)
{
int rc = 0;
@@ -289,7 +290,7 @@ static int lxcContainerRenameAndEnableInterfaces(unsigned int nveths,
}
/* enable lo device only if there were other net devices */
- if (veths)
+ if (veths || privNet)
rc = virNetDevSetOnline("lo", true);
error_out:
@@ -1343,7 +1344,9 @@ static int lxcContainerChild( void *data )
VIR_DEBUG("Received container continue message");
/* rename and enable interfaces */
- if (lxcContainerRenameAndEnableInterfaces(argv->nveths,
+ if (lxcContainerRenameAndEnableInterfaces(!!(vmDef->features &
+ (1 << VIR_DOMAIN_FEATURE_PRIVNET)),
+ argv->nveths,
argv->veths) < 0) {
goto cleanup;
}
@@ -1458,7 +1461,8 @@ int lxcContainerStart(virDomainDefPtr def,
cflags |= CLONE_NEWUSER;
}
- if (def->nets != NULL) {
+ if (def->nets != NULL ||
+ (def->features & (1 << VIR_DOMAIN_FEATURE_PRIVNET))) {
VIR_DEBUG("Enable network namespaces");
cflags |= CLONE_NEWNET;
}
--
1.7.7.6
12 years, 8 months
[libvirt] [PATCH] sanlock: Enhance error message to point to possible problem with selinux
by Peter Krempa
If the connection to the sanlock daemon is forbidden by selinux the
error message was not clear enough. This patch adds a check if proper
configuration for selinux is used while trying to connect to sanlock.
*src/locking/lock_driver_sanlock.c:
- add macro virLockSystemError that checks for selinux and
reports an improved error message
- modify calls of virReportSystemError to the new macro in
apropriate places
Background:
https://bugzilla.redhat.com/show_bug.cgi?id=770488
---
src/locking/lock_driver_sanlock.c | 83 +++++++++++++++++++++++--------------
1 files changed, 52 insertions(+), 31 deletions(-)
diff --git a/src/locking/lock_driver_sanlock.c b/src/locking/lock_driver_sanlock.c
index d344d6a..d5634f9 100644
--- a/src/locking/lock_driver_sanlock.c
+++ b/src/locking/lock_driver_sanlock.c
@@ -35,6 +35,10 @@
#include <sanlock_resource.h>
#include <sanlock_admin.h>
+#if HAVE_SELINUX
+# include <selinux/selinux.h>
+#endif
+
#include "lock_driver.h"
#include "logging.h"
#include "virterror_internal.h"
@@ -51,7 +55,23 @@
#define virLockError(code, ...) \
virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
-
+#if HAVE_SELINUX
+# define virLockSystemError(theerrno, format, ...) \
+ do { \
+ if ((theerrno)==EACCES && \
+ security_get_boolean_active("virt_use_sanlock") == 0) { \
+ char errbuff[1024]; \
+ snprintf(errbuff, sizeof(errbuff), "%s %s", (format), \
+ _("(Consider setting virt_use_sanlock selinux variable)"));\
+ virReportSystemError((theerrno), errbuff, __VA_ARGS__); \
+ } else { \
+ virReportSystemError((theerrno), (format), __VA_ARGS__); \
+ } \
+ } while(0);
+#else
+# define virLockSystemError(...) \
+ virReportSystemError(__VA_ARGS__);
+#endif
#define VIR_LOCK_MANAGER_SANLOCK_AUTO_DISK_LOCKSPACE "__LIBVIRT__DISKS__"
@@ -186,9 +206,9 @@ static int virLockManagerSanlockSetupLockspace(void)
_("Unable to query sector size %s: error %d"),
path, rv);
else
- virReportSystemError(-rv,
- _("Unable to query sector size %s"),
- path);
+ virLockSystemError(-rv,
+ _("Unable to query sector size %s"),
+ path);
goto error_unlink;
}
@@ -215,9 +235,9 @@ static int virLockManagerSanlockSetupLockspace(void)
_("Unable to initialize lockspace %s: error %d"),
path, rv);
else
- virReportSystemError(-rv,
- _("Unable to initialize lockspace %s"),
- path);
+ virLockSystemError(-rv,
+ _("Unable to initialize lockspace %s"),
+ path);
goto error_unlink;
}
VIR_DEBUG("Lockspace %s has been initialized", path);
@@ -236,9 +256,9 @@ static int virLockManagerSanlockSetupLockspace(void)
_("Unable to add lockspace %s: error %d"),
path, rv);
else
- virReportSystemError(-rv,
- _("Unable to add lockspace %s"),
- path);
+ virLockSystemError(-rv,
+ _("Unable to add lockspace %s"),
+ path);
goto error_unlink;
} else {
VIR_DEBUG("Lockspace %s is already registered", path);
@@ -559,9 +579,9 @@ static int virLockManagerSanlockCreateLease(struct sanlk_resource *res)
_("Unable to query sector size %s: error %d"),
res->disks[0].path, rv);
else
- virReportSystemError(-rv,
- _("Unable to query sector size %s"),
- res->disks[0].path);
+ virLockSystemError(-rv,
+ _("Unable to query sector size %s"),
+ res->disks[0].path);
goto error_unlink;
}
@@ -588,9 +608,9 @@ static int virLockManagerSanlockCreateLease(struct sanlk_resource *res)
_("Unable to initialize lease %s: error %d"),
res->disks[0].path, rv);
else
- virReportSystemError(-rv,
- _("Unable to initialize lease %s"),
- res->disks[0].path);
+ virLockSystemError(-rv,
+ _("Unable to initialize lease %s"),
+ res->disks[0].path);
goto error_unlink;
}
VIR_DEBUG("Lease %s has been initialized", res->disks[0].path);
@@ -711,9 +731,9 @@ static int virLockManagerSanlockAcquire(virLockManagerPtr lock,
_("Unable to parse lock state %s: error %d"),
state, rv);
else
- virReportSystemError(-rv,
- _("Unable to parse lock state %s"),
- state);
+ virLockSystemError(-rv,
+ _("Unable to parse lock state %s"),
+ state);
goto error;
}
res_free = true;
@@ -736,8 +756,9 @@ static int virLockManagerSanlockAcquire(virLockManagerPtr lock,
_("Failed to open socket to sanlock daemon: error %d"),
sock);
else
- virReportSystemError(-sock, "%s",
- _("Failed to open socket to sanlock daemon"));
+ virLockSystemError(-sock, "%s",
+ _("Failed to open socket to sanlock daemon"));
+
goto error;
}
@@ -750,8 +771,8 @@ static int virLockManagerSanlockAcquire(virLockManagerPtr lock,
virLockError(VIR_ERR_INTERNAL_ERROR,
_("Failed to acquire lock: error %d"), rv);
else
- virReportSystemError(-rv, "%s",
- _("Failed to acquire lock"));
+ virLockSystemError(-rv, "%s",
+ _("Failed to acquire lock"));
goto error;
}
}
@@ -774,8 +795,8 @@ static int virLockManagerSanlockAcquire(virLockManagerPtr lock,
virLockError(VIR_ERR_INTERNAL_ERROR,
_("Failed to restrict process: error %d"), rv);
else
- virReportSystemError(-rv, "%s",
- _("Failed to restrict process"));
+ virLockSystemError(-rv, "%s",
+ _("Failed to restrict process"));
goto error;
}
}
@@ -823,8 +844,8 @@ static int virLockManagerSanlockRelease(virLockManagerPtr lock,
virLockError(VIR_ERR_INTERNAL_ERROR,
_("Failed to inquire lock: error %d"), rv);
else
- virReportSystemError(-rv, "%s",
- _("Failed to inquire lock"));
+ virLockSystemError(-rv, "%s",
+ _("Failed to inquire lock"));
return -1;
}
@@ -837,8 +858,8 @@ static int virLockManagerSanlockRelease(virLockManagerPtr lock,
virLockError(VIR_ERR_INTERNAL_ERROR,
_("Failed to release lock: error %d"), rv);
else
- virReportSystemError(-rv, "%s",
- _("Failed to release lock"));
+ virLockSystemError(-rv, "%s",
+ _("Failed to release lock"));
return -1;
}
@@ -866,8 +887,8 @@ static int virLockManagerSanlockInquire(virLockManagerPtr lock,
virLockError(VIR_ERR_INTERNAL_ERROR,
_("Failed to inquire lock: error %d"), rv);
else
- virReportSystemError(-rv, "%s",
- _("Failed to inquire lock"));
+ virLockSystemError(-rv, "%s",
+ _("Failed to inquire lock"));
return -1;
}
--
1.7.3.4
12 years, 8 months
[libvirt] [PATCH] lib: Don't access configuration if none is present
by Peter Krempa
Commit e457d5ef2015e6106094b85f8bbd1582002edc4d adds ability to pass the
default URI using the client configuration file. If the file is not
present, it still accesses the NULL config object causing a segfault.
Caught running "make check".
---
src/libvirt.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/src/libvirt.c b/src/libvirt.c
index 1c0cdf7..d0b1b28 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -1085,7 +1085,8 @@ virConnectOpenResolveURIAlias(virConfPtr conf,
*uri = NULL;
- if ((value = virConfGetValue(conf, "uri_aliases")))
+ if (conf &&
+ (value = virConfGetValue(conf, "uri_aliases")))
ret = virConnectOpenFindURIAliasMatch(value, alias, uri);
else
ret = 0;
--
1.7.3.4
12 years, 8 months
[libvirt] [PATCH] Emit graphics events when a SPICE client connects/disconnects
by Laine Stump
Wire up the domain graphics event notifications for SPICE. Adapted
from a RHEL-only patch written by Dan Berrange that used custom
__com.redhat_SPICE events - equivalent events are now available in
upstream QEMU (including a SPICE_CONNECTED event, which was missing in
the __COM.redhat_SPICE version).
* src/qemu/qemu_monitor_json.c: Wire up SPICE graphics events
---
src/qemu/qemu_monitor_json.c | 56 +++++++++++++++++++++++++++++++++++++++---
1 files changed, 52 insertions(+), 4 deletions(-)
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 1a0ee94..a5ef1d4 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -59,6 +59,9 @@ static void qemuMonitorJSONHandleVNCConnect(qemuMonitorPtr mon, virJSONValuePtr
static void qemuMonitorJSONHandleVNCInitialize(qemuMonitorPtr mon, virJSONValuePtr data);
static void qemuMonitorJSONHandleVNCDisconnect(qemuMonitorPtr mon, virJSONValuePtr data);
static void qemuMonitorJSONHandleBlockJob(qemuMonitorPtr mon, virJSONValuePtr data);
+static void qemuMonitorJSONHandleSPICEConnect(qemuMonitorPtr mon, virJSONValuePtr data);
+static void qemuMonitorJSONHandleSPICEInitialize(qemuMonitorPtr mon, virJSONValuePtr data);
+static void qemuMonitorJSONHandleSPICEDisconnect(qemuMonitorPtr mon, virJSONValuePtr data);
static struct {
const char *type;
@@ -75,6 +78,9 @@ static struct {
{ "VNC_INITIALIZED", qemuMonitorJSONHandleVNCInitialize, },
{ "VNC_DISCONNECTED", qemuMonitorJSONHandleVNCDisconnect, },
{ "BLOCK_JOB_COMPLETED", qemuMonitorJSONHandleBlockJob, },
+ { "SPICE_CONNECTED", qemuMonitorJSONHandleSPICEConnect, },
+ { "SPICE_INITIALIZED", qemuMonitorJSONHandleSPICEInitialize, },
+ { "SPICE_DISCONNECTED", qemuMonitorJSONHandleSPICEDisconnect, },
};
@@ -624,7 +630,7 @@ VIR_ENUM_IMPL(qemuMonitorGraphicsAddressFamily,
VIR_DOMAIN_EVENT_GRAPHICS_ADDRESS_LAST,
"ipv4", "ipv6", "unix");
-static void qemuMonitorJSONHandleVNC(qemuMonitorPtr mon, virJSONValuePtr data, int phase)
+static void qemuMonitorJSONHandleGraphics(qemuMonitorPtr mon, virJSONValuePtr data, int phase)
{
const char *localNode, *localService, *localFamily;
const char *remoteNode, *remoteService, *remoteFamily;
@@ -643,14 +649,38 @@ static void qemuMonitorJSONHandleVNC(qemuMonitorPtr mon, virJSONValuePtr data, i
}
authScheme = virJSONValueObjectGetString(server, "auth");
+ if (!authScheme) {
+ VIR_WARN("missing auth scheme in graphics event");
+ return;
+ }
localFamily = virJSONValueObjectGetString(server, "family");
+ if (!authScheme) {
+ VIR_WARN("missing local address family in graphics event");
+ return;
+ }
localNode = virJSONValueObjectGetString(server, "host");
+ if (!authScheme) {
+ VIR_WARN("missing local hostname in graphics event");
+ return;
+ }
localService = virJSONValueObjectGetString(server, "service");
+ if (!localService)
+ localService = ""; /* Spice has multiple ports, so this isn't provided */
remoteFamily = virJSONValueObjectGetString(client, "family");
+ if (!authScheme) {
+ VIR_WARN("missing remote address family in graphics event");
+ return;
+ }
remoteNode = virJSONValueObjectGetString(client, "host");
+ if (!authScheme) {
+ VIR_WARN("missing remote hostname in graphics event");
+ return;
+ }
remoteService = virJSONValueObjectGetString(client, "service");
+ if (!remoteService)
+ remoteService = ""; /* Spice has multiple ports, so this isn't provided */
saslUsername = virJSONValueObjectGetString(client, "sasl_username");
x509dname = virJSONValueObjectGetString(client, "x509_dname");
@@ -672,19 +702,37 @@ static void qemuMonitorJSONHandleVNC(qemuMonitorPtr mon, virJSONValuePtr data, i
static void qemuMonitorJSONHandleVNCConnect(qemuMonitorPtr mon, virJSONValuePtr data)
{
- qemuMonitorJSONHandleVNC(mon, data, VIR_DOMAIN_EVENT_GRAPHICS_CONNECT);
+ qemuMonitorJSONHandleGraphics(mon, data, VIR_DOMAIN_EVENT_GRAPHICS_CONNECT);
}
static void qemuMonitorJSONHandleVNCInitialize(qemuMonitorPtr mon, virJSONValuePtr data)
{
- qemuMonitorJSONHandleVNC(mon, data, VIR_DOMAIN_EVENT_GRAPHICS_INITIALIZE);
+ qemuMonitorJSONHandleGraphics(mon, data, VIR_DOMAIN_EVENT_GRAPHICS_INITIALIZE);
}
static void qemuMonitorJSONHandleVNCDisconnect(qemuMonitorPtr mon, virJSONValuePtr data)
{
- qemuMonitorJSONHandleVNC(mon, data, VIR_DOMAIN_EVENT_GRAPHICS_DISCONNECT);
+ qemuMonitorJSONHandleGraphics(mon, data, VIR_DOMAIN_EVENT_GRAPHICS_DISCONNECT);
+}
+
+
+static void qemuMonitorJSONHandleSPICEConnect(qemuMonitorPtr mon, virJSONValuePtr data)
+{
+ qemuMonitorJSONHandleGraphics(mon, data, VIR_DOMAIN_EVENT_GRAPHICS_CONNECT);
+}
+
+
+static void qemuMonitorJSONHandleSPICEInitialize(qemuMonitorPtr mon, virJSONValuePtr data)
+{
+ qemuMonitorJSONHandleGraphics(mon, data, VIR_DOMAIN_EVENT_GRAPHICS_INITIALIZE);
+}
+
+
+static void qemuMonitorJSONHandleSPICEDisconnect(qemuMonitorPtr mon, virJSONValuePtr data)
+{
+ qemuMonitorJSONHandleGraphics(mon, data, VIR_DOMAIN_EVENT_GRAPHICS_DISCONNECT);
}
static void qemuMonitorJSONHandleBlockJob(qemuMonitorPtr mon, virJSONValuePtr data)
--
1.7.7.6
12 years, 8 months
[libvirt] [PATCH] qemuDomainDetachPciDiskDevice: Free allocated cgroup
by Michal Privoznik
This function potentially allocates new virCgroup but never
frees it.
---
src/qemu/qemu_hotplug.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index e088a49..f1c1283 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -1621,6 +1621,7 @@ int qemuDomainDetachPciDiskDevice(struct qemud_driver *driver,
ret = 0;
cleanup:
+ virCgroupFree(&cgroup);
VIR_FREE(drivestr);
return ret;
}
--
1.7.8.5
12 years, 8 months
[libvirt] [PATCH] qemu: Split ide-drive into ide-cd and ide-hd
by Osier Yang
A "ide-drive" device can be either a hard disk or a CD-ROM,
if there is ",media=cdrom" specified for the backend, it's
a CD-ROM, otherwise it's a hard disk.
Upstream qemu splitted "ide-drive" into "ide-hd" and "ide-cd"
since commit 1f56e32, and ",media=cdrom" is not required for
ide-cd anymore. "ide-drive" is still supported for backwards
compatibility, but no doubt we should go foward.
---
src/qemu/qemu_capabilities.c | 4 ++
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_command.c | 26 +++++++++++++++-
tests/qemuhelptest.c | 3 +-
.../qemuxml2argv-disk-ide-drive-split.args | 8 +++++
.../qemuxml2argv-disk-ide-drive-split.xml | 32 ++++++++++++++++++++
tests/qemuxml2argvtest.c | 3 ++
7 files changed, 74 insertions(+), 3 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-ide-drive-split.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-ide-drive-split.xml
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index c4b04ae..1f999a7 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -156,6 +156,8 @@ VIR_ENUM_IMPL(qemuCaps, QEMU_CAPS_LAST,
"scsi-disk.channel",
"scsi-block",
"scsi-cd",
+
+ "ide-cd", /* 90 */
);
struct qemu_feature_flags {
@@ -1450,6 +1452,8 @@ qemuCapsParseDeviceStr(const char *str, virBitmapPtr flags)
qemuCapsSet(flags, QEMU_CAPS_SCSI_BLOCK);
if (strstr(str, "scsi-cd"))
qemuCapsSet(flags, QEMU_CAPS_SCSI_CD);
+ if (strstr(str, "ide-cd"))
+ qemuCapsSet(flags, QEMU_CAPS_IDE_CD);
return 0;
}
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 5ebffdc..e664f29 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -124,6 +124,7 @@ enum qemuCapsFlags {
QEMU_CAPS_SCSI_DISK_CHANNEL = 87, /* Is scsi-disk.channel available? */
QEMU_CAPS_SCSI_BLOCK = 88, /* -device scsi-block */
QEMU_CAPS_SCSI_CD = 89, /* -device scsi-cd */
+ QEMU_CAPS_IDE_CD = 90, /* -device ide-cd */
QEMU_CAPS_LAST, /* this must always be the last item */
};
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index afe5db8..9a02a80 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1971,6 +1971,9 @@ qemuBuildDriveStr(virConnectPtr conn ATTRIBUTE_UNUSED,
if ((disk->bus == VIR_DOMAIN_DISK_BUS_SCSI)) {
if (!qemuCapsGet(qemuCaps, QEMU_CAPS_SCSI_CD))
virBufferAddLit(&opt, ",media=cdrom");
+ } else if (disk->bus == VIR_DOMAIN_DISK_BUS_IDE) {
+ if (!qemuCapsGet(qemuCaps, QEMU_CAPS_IDE_CD))
+ virBufferAddLit(&opt, ",media=cdrom");
} else {
virBufferAddLit(&opt, ",media=cdrom");
}
@@ -2194,7 +2197,16 @@ qemuBuildDriveDevStr(virDomainDefPtr def,
_("target must be 0 for ide controller"));
goto error;
}
- virBufferAddLit(&opt, "ide-drive");
+
+ if (qemuCapsGet(qemuCaps, QEMU_CAPS_IDE_CD)) {
+ if (disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM)
+ virBufferAddLit(&opt, "ide-cd");
+ else
+ virBufferAddLit(&opt, "ide-hd");
+ } else {
+ virBufferAddLit(&opt, "ide-drive");
+ }
+
virBufferAsprintf(&opt, ",bus=ide.%d,unit=%d",
disk->info.addr.drive.bus,
disk->info.addr.drive.unit);
@@ -2285,12 +2297,22 @@ qemuBuildDriveDevStr(virDomainDefPtr def,
_("bus must be 0 for ide controller"));
goto error;
}
+
if (disk->info.addr.drive.target != 0) {
qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("target must be 0 for ide controller"));
goto error;
}
- virBufferAddLit(&opt, "ide-drive");
+
+ if (qemuCapsGet(qemuCaps, QEMU_CAPS_IDE_CD)) {
+ if (disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM)
+ virBufferAddLit(&opt, "ide-cd");
+ else
+ virBufferAddLit(&opt, "ide-hd");
+ } else {
+ virBufferAddLit(&opt, "ide-drive");
+ }
+
virBufferAsprintf(&opt, ",bus=ahci%d.%d",
disk->info.addr.drive.controller,
disk->info.addr.drive.unit);
diff --git a/tests/qemuhelptest.c b/tests/qemuhelptest.c
index a01c389..d23b35a 100644
--- a/tests/qemuhelptest.c
+++ b/tests/qemuhelptest.c
@@ -676,7 +676,8 @@ mymain(void)
QEMU_CAPS_CPU_HOST,
QEMU_CAPS_FSDEV_WRITEOUT,
QEMU_CAPS_SCSI_BLOCK,
- QEMU_CAPS_SCSI_CD);
+ QEMU_CAPS_SCSI_CD,
+ QEMU_CAPS_IDE_CD);
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
}
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-ide-drive-split.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-ide-drive-split.args
new file mode 100644
index 0000000..e24490d
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-ide-drive-split.args
@@ -0,0 +1,8 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test \
+/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -nodefconfig -nodefaults \
+-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c \
+-drive file=/dev/HostVG/QEMUGuest1,if=none,id=drive-ide0-0-1 \
+-device ide-cd,bus=ide.0,unit=1,drive=drive-ide0-0-1,id=ide0-0-1 \
+-drive file=/tmp/idedisk.img,if=none,id=drive-ide0-0-2 \
+-device ide-hd,bus=ide.0,unit=2,drive=drive-ide0-0-2,id=ide0-0-2 \
+-usb -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-ide-drive-split.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-ide-drive-split.xml
new file mode 100644
index 0000000..b965677
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-ide-drive-split.xml
@@ -0,0 +1,32 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219136</memory>
+ <currentMemory unit='KiB'>219136</currentMemory>
+ <vcpu>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu</emulator>
+ <disk type='block' device='cdrom'>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0' target='0' unit='1'/>
+ </disk>
+ <disk type='file' device='disk'>
+ <source file='/tmp/idedisk.img'/>
+ <target dev='hdc' bus='ide'/>
+ <address type='drive' controller='0' bus='0' target='0' unit='2'/>
+ </disk>
+ <controller type='usb' index='0'/>
+ <controller type='ide' index='0'/>
+ <controller type='ide' index='1'/>
+ <memballoon model='virtio'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 97e2bac..b503ddc 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -753,6 +753,9 @@ mymain(void)
DO_TEST("pseries-vio-address-clash", true, QEMU_CAPS_DRIVE,
QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
+ DO_TEST("disk-ide-drive-split", false,
+ QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
+ QEMU_CAPS_IDE_CD);
VIR_FREE(driver.stateDir);
virCapabilitiesFree(driver.caps);
VIR_FREE(map);
--
1.7.1
12 years, 8 months
[libvirt] [PATCH] qemu: Split scsi-disk into into scsi-hd and scsi-cd
by Osier Yang
A "scsi-disk" device can be either a hard disk or a CD-ROM,
if there is ",media=cdrom" specified for the backend, it's
a CD-ROM, otherwise it's a hard disk.
But upstream qemu splitted "scsi-disk" into "scsi-hd" and
"scsi-cd" since commit b443ae, and ",media=cdrom" is not
required for scsi-cd anymore. "scsi-disk" is still supported
for backwards compatibility, but no doubt we should go
foward.
---
src/qemu/qemu_capabilities.c | 3 +
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_command.c | 39 ++++++++++++++----
tests/qemuhelptest.c | 6 ++-
.../qemuxml2argv-disk-scsi-disk-split.args | 16 +++++++
.../qemuxml2argv-disk-scsi-disk-split.xml | 44 ++++++++++++++++++++
tests/qemuxml2argvtest.c | 3 +
7 files changed, 102 insertions(+), 10 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-disk-split.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-disk-split.xml
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index ace5011..c4b04ae 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -155,6 +155,7 @@ VIR_ENUM_IMPL(qemuCaps, QEMU_CAPS_LAST,
"system_wakeup",
"scsi-disk.channel",
"scsi-block",
+ "scsi-cd",
);
struct qemu_feature_flags {
@@ -1447,6 +1448,8 @@ qemuCapsParseDeviceStr(const char *str, virBitmapPtr flags)
qemuCapsSet(flags, QEMU_CAPS_SCSI_DISK_CHANNEL);
if (strstr(str, "scsi-block"))
qemuCapsSet(flags, QEMU_CAPS_SCSI_BLOCK);
+ if (strstr(str, "scsi-cd"))
+ qemuCapsSet(flags, QEMU_CAPS_SCSI_CD);
return 0;
}
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 62b4270..5ebffdc 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -123,6 +123,7 @@ enum qemuCapsFlags {
QEMU_CAPS_WAKEUP = 86, /* system_wakeup monitor command */
QEMU_CAPS_SCSI_DISK_CHANNEL = 87, /* Is scsi-disk.channel available? */
QEMU_CAPS_SCSI_BLOCK = 88, /* -device scsi-block */
+ QEMU_CAPS_SCSI_CD = 89, /* -device scsi-cd */
QEMU_CAPS_LAST, /* this must always be the last item */
};
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 3b9eec8..afe5db8 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1967,8 +1967,14 @@ qemuBuildDriveStr(virConnectPtr conn ATTRIBUTE_UNUSED,
else
virBufferAsprintf(&opt, "if=%s", bus);
- if (disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM)
- virBufferAddLit(&opt, ",media=cdrom");
+ if (disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM) {
+ if ((disk->bus == VIR_DOMAIN_DISK_BUS_SCSI)) {
+ if (!qemuCapsGet(qemuCaps, QEMU_CAPS_SCSI_CD))
+ virBufferAddLit(&opt, ",media=cdrom");
+ } else {
+ virBufferAddLit(&opt, ",media=cdrom");
+ }
+ }
if (qemuCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
virBufferAsprintf(&opt, ",id=%s%s", QEMU_DRIVE_HOST_PREFIX, disk->info.alias);
@@ -2218,10 +2224,19 @@ qemuBuildDriveDevStr(virDomainDefPtr def,
goto error;
}
- if (disk->device == VIR_DOMAIN_DISK_DEVICE_LUN)
+ if (disk->device == VIR_DOMAIN_DISK_DEVICE_LUN) {
virBufferAddLit(&opt, "scsi-block");
- else
- virBufferAddLit(&opt, "scsi-disk");
+ } else {
+ if (qemuCapsGet(qemuCaps, QEMU_CAPS_SCSI_CD)) {
+ if (disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM)
+ virBufferAddLit(&opt, "scsi-cd");
+ else
+ virBufferAddLit(&opt, "scsi-hd");
+ } else {
+ virBufferAddLit(&opt, "scsi-disk");
+ }
+ }
+
virBufferAsprintf(&opt, ",bus=scsi%d.%d,scsi-id=%d",
disk->info.addr.drive.controller,
disk->info.addr.drive.bus,
@@ -2244,10 +2259,18 @@ qemuBuildDriveDevStr(virDomainDefPtr def,
}
}
- if (disk->device != VIR_DOMAIN_DISK_DEVICE_LUN)
- virBufferAddLit(&opt, "scsi-disk");
- else
+ if (disk->device != VIR_DOMAIN_DISK_DEVICE_LUN) {
+ if (qemuCapsGet(qemuCaps, QEMU_CAPS_SCSI_CD)) {
+ if (disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM)
+ virBufferAddLit(&opt, "scsi-cd");
+ else
+ virBufferAddLit(&opt, "scsi-hd");
+ } else {
+ virBufferAddLit(&opt, "scsi-disk");
+ }
+ } else {
virBufferAddLit(&opt, "scsi-block");
+ }
virBufferAsprintf(&opt, ",bus=scsi%d.0,channel=%d,scsi-id=%d,lun=%d",
disk->info.addr.drive.controller,
diff --git a/tests/qemuhelptest.c b/tests/qemuhelptest.c
index 05fdc4d..a01c389 100644
--- a/tests/qemuhelptest.c
+++ b/tests/qemuhelptest.c
@@ -605,7 +605,8 @@ mymain(void)
QEMU_CAPS_VIRTIO_BLK_SCSI,
QEMU_CAPS_VIRTIO_BLK_SG_IO,
QEMU_CAPS_DRIVE_COPY_ON_READ,
- QEMU_CAPS_CPU_HOST);
+ QEMU_CAPS_CPU_HOST,
+ QEMU_CAPS_SCSI_CD);
DO_TEST("qemu-1.0", 1000000, 0, 0,
QEMU_CAPS_VNC_COLON,
QEMU_CAPS_NO_REBOOT,
@@ -674,7 +675,8 @@ mymain(void)
QEMU_CAPS_VIRTIO_BLK_SG_IO,
QEMU_CAPS_CPU_HOST,
QEMU_CAPS_FSDEV_WRITEOUT,
- QEMU_CAPS_SCSI_BLOCK);
+ QEMU_CAPS_SCSI_BLOCK,
+ QEMU_CAPS_SCSI_CD);
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
}
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-disk-split.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-disk-split.args
new file mode 100644
index 0000000..a79299a
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-disk-split.args
@@ -0,0 +1,16 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test \
+/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -nodefconfig -nodefaults \
+-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c \
+-device virtio-scsi-pci,id=scsi0,bus=pci.0,addr=0x3 \
+-device lsi,id=scsi1,bus=pci.0,addr=0x4 \
+-device lsi,id=scsi2,bus=pci.0,addr=0x5 \
+-device virtio-scsi-pci,id=scsi3,bus=pci.0,addr=0x6 \
+-drive file=/dev/HostVG/QEMUGuest1,if=none,id=drive-scsi0-0-1-0 \
+-device scsi-cd,bus=scsi0.0,channel=0,scsi-id=1,lun=0,drive=drive-scsi0-0-1-0,id=scsi0-0-1-0 \
+-drive file=/dev/HostVG/QEMUGuest2,if=none,id=drive-scsi0-0-0-0 \
+-device scsi-cd,bus=scsi0.0,channel=0,scsi-id=0,lun=0,drive=drive-scsi0-0-0-0,id=scsi0-0-0-0 \
+-drive file=/tmp/scsidisk.img,if=none,id=drive-scsi0-0-0-1 \
+-device scsi-hd,bus=scsi0.0,channel=0,scsi-id=0,lun=1,drive=drive-scsi0-0-0-1,id=scsi0-0-0-1 \
+-drive file=/tmp/scsidisk.img,if=none,id=drive-scsi0-0-1-1 \
+-device scsi-hd,bus=scsi0.0,channel=0,scsi-id=1,lun=1,drive=drive-scsi0-0-1-1,id=scsi0-0-1-1 \
+-usb -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x7
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-disk-split.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-disk-split.xml
new file mode 100644
index 0000000..02181fd
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-disk-split.xml
@@ -0,0 +1,44 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219136</memory>
+ <currentMemory unit='KiB'>219136</currentMemory>
+ <vcpu>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu</emulator>
+ <disk type='block' device='cdrom'>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='sda' bus='scsi'/>
+ <address type='drive' controller='0' bus='0' target='1' unit='0'/>
+ </disk>
+ <disk type='block' device='cdrom'>
+ <source dev='/dev/HostVG/QEMUGuest2'/>
+ <target dev='sda' bus='scsi'/>
+ <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+ </disk>
+ <disk type='file' device='disk'>
+ <source file='/tmp/scsidisk.img'/>
+ <target dev='sdc' bus='scsi'/>
+ <address type='drive' controller='0' bus='0' target='0' unit='1'/>
+ </disk>
+ <disk type='file' device='disk'>
+ <source file='/tmp/scsidisk.img'/>
+ <target dev='sdd' bus='scsi'/>
+ <address type='drive' controller='0' bus='0' target='1' unit='1'/>
+ </disk>
+ <controller type='usb' index='0'/>
+ <controller type='scsi' index='0' model='virtio-scsi'/>
+ <controller type='scsi' index='1' model='lsilogic'/>
+ <controller type='scsi' index='2' model='lsilogic'/>
+ <controller type='scsi' index='3' model='virtio-scsi'/>
+ <memballoon model='virtio'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index d0affc7..97e2bac 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -457,6 +457,9 @@ mymain(void)
QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
DO_TEST("disk-scsi-device-auto", false,
QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
+ DO_TEST("disk-scsi-disk-split", false,
+ QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
+ QEMU_CAPS_SCSI_CD);
DO_TEST("disk-scsi-vscsi", false,
QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
DO_TEST("disk-scsi-virtio-scsi", false,
--
1.7.1
12 years, 8 months
[libvirt] [PATCH] numad: Fix typo and warning
by Osier Yang
src/libvirt_private.syms:
s/virDomainCpuPlacement/virDomainCpuPlacementMode/
src/qemu/qemu_process.c
def->mem.cur_balloon expects "llu"
--
pushed under build-breaker rule
---
src/libvirt_private.syms | 4 ++--
src/qemu/qemu_process.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index d58082a..e40c80e 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -271,8 +271,8 @@ virDomainControllerModelSCSITypeToString;
virDomainControllerModelUSBTypeFromString;
virDomainControllerModelUSBTypeToString;
virDomainControllerTypeToString;
-virDomainCpuPlacementTypeFromString;
-virDomainCpuPlacementTypeToString;
+virDomainCpuPlacementModeTypeFromString;
+virDomainCpuPlacementModeTypeToString;
virDomainCpuSetFormat;
virDomainCpuSetParse;
virDomainDefAddImplicitControllers;
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 56cb531..0af3751 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -1641,7 +1641,7 @@ qemuGetNumadAdvice(virDomainDefPtr def)
char *args = NULL;
char *output = NULL;
- if (virAsprintf(&args, "%d:%lu", def->vcpus, def->mem.cur_balloon) < 0) {
+ if (virAsprintf(&args, "%d:%llu", def->vcpus, def->mem.cur_balloon) < 0) {
virReportOOMError();
goto out;
}
--
1.7.1
12 years, 8 months