[libvirt] [PATCH] network: truncate bridges' dummy tap device names to IFNAMSIZ (15) chars
by Laine Stump
This patch addresses:
https://bugzilla.redhat.com/show_bug.cgi?id=694382
In order to give each libvirt-created bridge a fixed MAC address,
commit 5754dbd56d4738112a86776c09e810e32f7c3224, added code to create
a dummy tap device with guaranteed lowest MAC address and attach it to
the bridge. This tap device was given the name "${bridgename}-nic".
However, an interface device name must be IFNAMSIZ (15) characters or
less, so a valid ${bridgename} such as "verylongname123" (15
characters) would lead to an invalid tap device name
("verylongname123-nic" - 19 characters), and that in turn led to a
failure to bring up the network.
The solution is to shorten the part of the original name used to
generate the tap device name. However, simply truncating it is
insufficient, because the last few characters of an interface name are
often a number used to indicate one of a list of several similar
devices (for example, "verylongname123", "verylongname124", etc) and
simple truncation would lead to duplicate names. So instead we take
the first 8 characters of $bridgename ("verylong" in the example), add
on the final 3 bytes ("123"), then add "-nic" (so "verylong123-nic").
Not pretty, but it is much more likely to generate a unique name, and
is reproducible (unlike, say, a random number).
---
src/network/bridge_driver.c | 14 +++++++++++++-
1 files changed, 13 insertions(+), 1 deletions(-)
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index ea2bfd4..ef89bf5 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -143,7 +143,19 @@ networkBridgeDummyNicName(const char *brname)
{
char *nicname;
- virAsprintf(&nicname, "%s-nic", brname);
+ if (strlen(brname) > (IFNAMSIZ - 5)) {
+ /* because the length of an ifname is limited to IFNAMSIZ-1
+ * (usually 15), and we're adding 4 more characters, we must
+ * truncate the original name to 11 to fit. In order to catch
+ * a possible numeric ending (eg virbr0, virbr1, etc), we grab
+ * the first 8 and last 3 characters of the string.
+ */
+ virAsprintf(&nicname, "%.*s%s-nic",
+ IFNAMSIZ - 8, /* space for last 3 chars + "-nic" + NULL */
+ brname, brname + strlen(brname) - 3);
+ } else {
+ virAsprintf(&nicname, "%s-nic", brname);
+ }
return nicname;
}
--
1.7.3.4
13 years, 7 months
[libvirt] [PATCH] ppc: Enable starting of VMs on ppc host
by Stefan Berger
Subject: ppc: Enable starting of VMs on ppc host
Due to differences in /proc/cpuinfo the parsing of the cpu data is
different between architectures. On PPC /proc/cpuinfo looks like this:
[original formatting with tabs]
processor : 0
cpu : PPC970MP, altivec supported
clock : 2297.700000MHz
revision : 1.1 (pvr 0044 0101)
processor : 1
cpu : PPC970MP, altivec supported
clock : 2297.700000MHz
revision : 1.1 (pvr 0044 0101)
[..]
timebase : 14318000
platform : pSeries
model : IBM,8844-AC1
machine : CHRP IBM,8844-AC1
The patch adapts the parsing of the data found in /proc/cpuinfo.
/sys/devices/system/cpu/cpuX/topology/physical_package_id also
always returns -1. Check for it on ppc and make it '0' if found negative.
Signed-off-by: Stefan Berger <stefanb(a)linux.vnet.ibm.com>
---
src/nodeinfo.c | 33 ++++++++++++++++++++++++++++++++-
1 file changed, 32 insertions(+), 1 deletion(-)
Index: libvirt/src/nodeinfo.c
===================================================================
--- libvirt.orig/src/nodeinfo.c
+++ libvirt/src/nodeinfo.c
@@ -163,7 +163,14 @@ cleanup:
static int parse_socket(unsigned int cpu)
{
- return get_cpu_value(cpu, "topology/physical_package_id", false);
+ int ret = get_cpu_value(cpu, "topology/physical_package_id", false);
+#if defined(__powerpc__) || \
+ defined(__powerpc64__)
+ /* ppc has -1 */
+ if (ret < 0)
+ ret = 0;
+#endif
+ return ret;
}
int linuxNodeInfoCPUPopulate(FILE *cpuinfo,
@@ -206,6 +213,9 @@ int linuxNodeInfoCPUPopulate(FILE *cpuin
return -1;
}
nodeinfo->cpus++;
+#if defined(__x86_64__) || \
+ defined(__amd64__) || \
+ defined(__i386__)
} else if (STRPREFIX(buf, "cpu MHz")) {
char *p;
unsigned int ui;
@@ -237,6 +247,27 @@ int linuxNodeInfoCPUPopulate(FILE *cpuin
&& id > nodeinfo->cores)
nodeinfo->cores = id;
}
+#elif defined(__powerpc__) || \
+ defined(__powerpc64__)
+ } else if (STRPREFIX(buf, "clock")) {
+ char *p;
+ unsigned int ui;
+ buf += 5;
+ while (*buf && c_isspace(*buf))
+ buf++;
+ if (*buf != ':' || !buf[1]) {
+ nodeReportError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("parsing cpuinfo cpu MHz"));
+ return -1;
+ }
+ if (virStrToLong_ui(buf+1, &p, 10, &ui) == 0
+ /* Accept trailing fractional part. */
+ && (*p == '\0' || *p == '.' || c_isspace(*p)))
+ nodeinfo->mhz = ui;
+ }
+#else
+# warning Parser for /proc/cpuinfo needs to be adapted for your
architecture
+#endif
}
if (!nodeinfo->cpus) {
13 years, 7 months
[libvirt] [PATCH] migrate VMs between different-endian hosts
by Stefan Berger
This patch enables the migration of Qemu VMs between hosts of different
endianess. I tested this by migrating a i686 VM between a x86 and ppc64
host.
I am converting the 'int's in the VM's state header to uint32_t assuming
this doesn't break compatibility with existing deployments other than Linux.
Signed-off-by: Stefan Berger <stefanb(a)linux.vnet.ibm.com>
---
src/qemu/qemu_driver.c | 25 ++++++++++++++++++++-----
1 file changed, 20 insertions(+), 5 deletions(-)
Index: libvirt-acl/src/qemu/qemu_driver.c
===================================================================
--- libvirt-acl.orig/src/qemu/qemu_driver.c
+++ libvirt-acl/src/qemu/qemu_driver.c
@@ -43,6 +43,7 @@
#include <sys/wait.h>
#include <sys/ioctl.h>
#include <sys/un.h>
+#include <byteswap.h>
#include "qemu_driver.h"
@@ -1881,13 +1882,22 @@ VIR_ENUM_IMPL(qemudSaveCompression, QEMU
struct qemud_save_header {
char magic[sizeof(QEMUD_SAVE_MAGIC)-1];
- int version;
- int xml_len;
- int was_running;
- int compressed;
- int unused[15];
+ uint32_t version;
+ uint32_t xml_len;
+ uint32_t was_running;
+ uint32_t compressed;
+ uint32_t unused[15];
};
+static inline void
+bswap_header(struct qemud_save_header *hdr) {
+ hdr->version = bswap_32(hdr->version);
+ hdr->xml_len = bswap_32(hdr->xml_len);
+ hdr->was_running = bswap_32(hdr->was_running);
+ hdr->compressed = bswap_32(hdr->compressed);
+}
+
+
/* return -errno on failure, or 0 on success */
static int
qemuDomainSaveHeader(int fd, const char *path, char *xml,
@@ -3097,6 +3107,11 @@ qemuDomainSaveImageOpen(struct qemud_dri
}
if (header.version > QEMUD_SAVE_VERSION) {
+ /* convert endianess and try again */
+ bswap_header(&header);
+ }
+
+ if (header.version > QEMUD_SAVE_VERSION) {
qemuReportError(VIR_ERR_OPERATION_FAILED,
_("image version is not supported (%d > %d)"),
header.version, QEMUD_SAVE_VERSION);
13 years, 7 months
[libvirt] [PATCH 0/4] more phyp refactoring
by Eric Blake
Phyp still had several memory leaks and in general some bad
copy-and-paste design. This series consolidates some common
patterns into simpler helpers, avoiding leaks in the process.
Eric Blake (4):
phyp: prefer memcpy over memmove when legal
phyp: avoid memory leaks in return values
phyp: avoid memory leaks in command values
phyp: another simplification
src/phyp/phyp_driver.c | 1128 +++++++-----------------------------------------
1 files changed, 163 insertions(+), 965 deletions(-)
--
1.7.4.2
13 years, 7 months
[libvirt] [PATCH] Fix gcc 4.6 warnings
by Christophe Fergeau
gcc 4.6 warns when a variable is initialized but isn't used afterwards:
vmware/vmware_driver.c:449:18: warning: variable 'vmxPath' set but not used [-Wunused-but-set-variable]
This patch fixes these warnings. There are still 2 offending files:
- vbox_tmpl.c: the variable is used inside an #ifdef and is assigned several
times outside of #ifdef. Fixing the warning would have required wrapping
all the assignment inside #ifdef which hurts readability.
vbox/vbox_tmpl.c: In function 'vboxAttachDrives':
vbox/vbox_tmpl.c:3918:22: warning: variable 'accessMode' set but not used [-Wunused-but-set-variable]
- esx_vi_types.generated.c: the name implies it's generated code and I
didn't want to dive into the code generator
esx/esx_vi_types.generated.c: In function 'esxVI_FileQueryFlags_Free':
esx/esx_vi_types.generated.c:1203:3: warning: variable 'item' set but not used [-Wunused-but-set-variable]
---
src/nwfilter/nwfilter_ebiptables_driver.c | 7 +++----
src/util/logging.c | 3 +--
src/vmware/vmware_driver.c | 2 +-
3 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/src/nwfilter/nwfilter_ebiptables_driver.c b/src/nwfilter/nwfilter_ebiptables_driver.c
index 6c9c470..977f74b 100644
--- a/src/nwfilter/nwfilter_ebiptables_driver.c
+++ b/src/nwfilter/nwfilter_ebiptables_driver.c
@@ -1634,7 +1634,7 @@ iptablesCreateRuleInstanceStateCtrl(virNWFilterDefPtr nwfilter,
bool isIPv6)
{
int rc;
- int directionIn = 0, directionOut = 0;
+ int directionIn = 0;
char chainPrefix[2];
bool maySkipICMP, inout = false;
char *matchState = NULL;
@@ -1643,9 +1643,8 @@ iptablesCreateRuleInstanceStateCtrl(virNWFilterDefPtr nwfilter,
if ((rule->tt == VIR_NWFILTER_RULE_DIRECTION_IN) ||
(rule->tt == VIR_NWFILTER_RULE_DIRECTION_INOUT)) {
directionIn = 1;
- directionOut = inout = (rule->tt == VIR_NWFILTER_RULE_DIRECTION_INOUT);
- } else
- directionOut = 1;
+ inout = (rule->tt == VIR_NWFILTER_RULE_DIRECTION_INOUT);
+ }
chainPrefix[0] = 'F';
diff --git a/src/util/logging.c b/src/util/logging.c
index 9d18752..bb3ba13 100644
--- a/src/util/logging.c
+++ b/src/util/logging.c
@@ -389,7 +389,7 @@ static void virLogDumpAllFD(const char *msg, int len) {
void
virLogEmergencyDumpAll(int signum) {
int len;
- int oldLogStart, oldLogLen, oldLogEnd;
+ int oldLogStart, oldLogLen;
switch (signum) {
#ifdef SIGFPE
@@ -444,7 +444,6 @@ virLogEmergencyDumpAll(int signum) {
* so it's best to reset it first.
*/
oldLogStart = virLogStart;
- oldLogEnd = virLogEnd;
oldLogLen = virLogLen;
virLogEnd = 0;
virLogLen = 0;
diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c
index b5e416b..bbfb1a4 100644
--- a/src/vmware/vmware_driver.c
+++ b/src/vmware/vmware_driver.c
@@ -467,7 +467,7 @@ vmwareDomainReboot(virDomainPtr dom, unsigned int flags ATTRIBUTE_UNUSED)
}
vmwareSetSentinal(cmd, vmw_types[driver->type]);
- vmwareSetSentinal(cmd, ((vmwareDomainPtr) vm->privateData)->vmxPath);
+ vmwareSetSentinal(cmd, vmxPath);
if (vm->state != VIR_DOMAIN_RUNNING) {
--
1.7.4.4
13 years, 7 months
[libvirt] [libvirt PATCH v3] Introduce virDomainChrDefNew()
by Michal Novotny
Make: passed
Make check: passed
Make syntax-check: passed
Hi,
this is the commit to introduce the function to create new character
device definition for the domain as advised by Cole Robinson
<crobinso(a)redhat.com>.
The function is used on the relevant places and also new tests has
been added.
Michal
Signed-off-by: Michal Novotny <minovotn(a)redhat.com>
---
src/conf/domain_conf.c | 20 +++++++++--
src/conf/domain_conf.h | 2 +
src/libvirt_private.syms | 1 +
src/qemu/qemu_command.c | 5 ++-
src/xenxs/xen_sxpr.c | 7 ++--
src/xenxs/xen_xm.c | 8 +++-
.../qemuxml2argv-serial-target-port-auto.xml | 31 ++++++++++++++++
.../qemuxml2xmlout-serial-target-port-auto.xml | 37 ++++++++++++++++++++
tests/qemuxml2xmltest.c | 1 +
9 files changed, 102 insertions(+), 10 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-serial-target-port-auto.xml
create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-target-port-auto.xml
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 90a1317..a80719c 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -3212,6 +3212,22 @@ error:
goto cleanup;
}
+/* Create a new character device definition and set
+ * default port.
+ */
+virDomainChrDefPtr
+virDomainChrDefNew(void) {
+ virDomainChrDefPtr def = NULL;
+
+ if (VIR_ALLOC(def) < 0) {
+ virReportOOMError();
+ return NULL;
+ }
+
+ def->target.port = -1;
+ return def;
+}
+
/* Parse the XML definition for a character device
* @param node XML nodeset to parse for net definition
*
@@ -3260,10 +3276,8 @@ virDomainChrDefParseXML(virCapsPtr caps,
virDomainChrDefPtr def;
int remaining;
- if (VIR_ALLOC(def) < 0) {
- virReportOOMError();
+ if (!(def = virDomainChrDefNew()))
return NULL;
- }
type = virXMLPropString(node, "type");
if (type == NULL) {
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 95bd11e..ecf44ca 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1229,6 +1229,8 @@ void virDomainObjRef(virDomainObjPtr vm);
/* Returns 1 if the object was freed, 0 if more refs exist */
int virDomainObjUnref(virDomainObjPtr vm) ATTRIBUTE_RETURN_CHECK;
+virDomainChrDefPtr virDomainChrDefNew(void);
+
/* live == true means def describes an active domain (being migrated or
* restored) as opposed to a new persistent configuration of the domain */
virDomainObjPtr virDomainAssignDef(virCapsPtr caps,
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 54e4482..4175ca0 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -201,6 +201,7 @@ virDomainChrConsoleTargetTypeFromString;
virDomainChrConsoleTargetTypeToString;
virDomainChrDefForeach;
virDomainChrDefFree;
+virDomainChrDefNew;
virDomainChrSourceDefFree;
virDomainChrSpicevmcTypeFromString;
virDomainChrSpicevmcTypeToString;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index fea0068..029ed7d 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -36,6 +36,7 @@
#include "c-ctype.h"
#include "domain_nwfilter.h"
#include "qemu_audit.h"
+#include "domain_conf.h"
#include <sys/utsname.h>
#include <sys/stat.h>
@@ -5315,8 +5316,8 @@ qemuParseCommandLineChr(const char *val)
{
virDomainChrDefPtr def;
- if (VIR_ALLOC(def) < 0)
- goto no_memory;
+ if (!(def = virDomainChrDefNew()))
+ goto error;
if (STREQ(val, "null")) {
def->source.type = VIR_DOMAIN_CHR_TYPE_NULL;
diff --git a/src/xenxs/xen_sxpr.c b/src/xenxs/xen_sxpr.c
index 3a412a6..b590517 100644
--- a/src/xenxs/xen_sxpr.c
+++ b/src/xenxs/xen_sxpr.c
@@ -168,10 +168,8 @@ xenParseSxprChar(const char *value,
char *tmp;
virDomainChrDefPtr def;
- if (VIR_ALLOC(def) < 0) {
- virReportOOMError();
+ if (!(def = virDomainChrDefNew()))
return NULL;
- }
prefix = value;
@@ -1328,6 +1326,7 @@ xenParseSxpr(const struct sexpr *root,
goto no_memory;
}
chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL;
+ chr->target.port = 0;
def->serials[def->nserials++] = chr;
}
}
@@ -1343,6 +1342,7 @@ xenParseSxpr(const struct sexpr *root,
goto no_memory;
}
chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL;
+ chr->target.port = 0;
def->parallels[def->nparallels++] = chr;
}
} else {
@@ -1350,6 +1350,7 @@ xenParseSxpr(const struct sexpr *root,
if (!(def->console = xenParseSxprChar("pty", tty)))
goto error;
def->console->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE;
+ def->console->target.port = 0;
def->console->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN;
}
VIR_FREE(tty);
diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
index 22ad788..89f75a5 100644
--- a/src/xenxs/xen_xm.c
+++ b/src/xenxs/xen_xm.c
@@ -36,6 +36,7 @@
#include "xenxs_private.h"
#include "xen_xm.h"
#include "xen_sxpr.h"
+#include "domain_conf.h"
/* Convenience method to grab a int from the config file object */
static int xenXMConfigGetBool(virConfPtr conf,
@@ -957,6 +958,7 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
goto no_memory;
}
chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL;
+ chr->target.port = 0;
def->parallels[0] = chr;
def->nparallels++;
chr = NULL;
@@ -981,8 +983,8 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
continue;
}
- if (VIR_ALLOC(chr) < 0)
- goto no_memory;
+ if (!(chr = virDomainChrDefNew()))
+ goto cleanup;
if (!(chr = xenParseSxprChar(port, NULL)))
goto cleanup;
@@ -1010,6 +1012,7 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
goto no_memory;
}
chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL;
+ chr->target.port = 0;
def->serials[0] = chr;
def->nserials++;
}
@@ -1018,6 +1021,7 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
if (!(def->console = xenParseSxprChar("pty", NULL)))
goto cleanup;
def->console->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE;
+ def->console->target.port = 0;
def->console->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN;
}
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-serial-target-port-auto.xml b/tests/qemuxml2argvdata/qemuxml2argv-serial-target-port-auto.xml
new file mode 100644
index 0000000..0f98f51
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-target-port-auto.xml
@@ -0,0 +1,31 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory>219100</memory>
+ <currentMemory>219100</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='disk'>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0' unit='0'/>
+ </disk>
+ <controller type='ide' index='0'/>
+ <serial type='pty'/>
+ <serial type='null'/>
+ <serial type='stdio'/>
+ <console type='pty'>
+ <target port='0'/>
+ </console>
+ <memballoon model='virtio'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-target-port-auto.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-target-port-auto.xml
new file mode 100644
index 0000000..878418a
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-target-port-auto.xml
@@ -0,0 +1,37 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory>219100</memory>
+ <currentMemory>219100</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='disk'>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0' unit='0'/>
+ </disk>
+ <controller type='ide' index='0'/>
+ <serial type='pty'>
+ <target port='0'/>
+ </serial>
+ <serial type='null'>
+ <target port='1'/>
+ </serial>
+ <serial type='stdio'>
+ <target port='2'/>
+ </serial>
+ <console type='pty'>
+ <target type='serial' port='0'/>
+ </console>
+ <memballoon model='virtio'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index b86dbee..27330a9 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -195,6 +195,7 @@ mymain(int argc, char **argv)
DO_TEST_DIFFERENT("console-compat-auto");
DO_TEST_DIFFERENT("disk-scsi-device-auto");
DO_TEST_DIFFERENT("console-virtio");
+ DO_TEST_DIFFERENT("serial-target-port-auto");
virCapabilitiesFree(driver.caps);
--
1.7.3.2
13 years, 7 months
[libvirt] [PATCH v2] Spice: support auid, images and stream compression
by Michal Privoznik
This extends the SPICE XML to allow variable compression settings for audio,
images and streaming:
<graphics type='spice' port='5901' tlsPort='-1' autoport='yes'>
<image compression='auto_glz'/>
<jpeg compression='auto'/>
<zlib compression='auto'/>
<playback compression='on'/>
</graphics>
All new element are optional.
---
Diff to v1:
- _DEFAULT in all enums
- VIR_ERR_CONFIG_UNSUPPORTED if TypeFromString fails
docs/formatdomain.html.in | 12 ++
docs/schemas/domain.rng | 50 ++++++++
src/conf/domain_conf.c | 125 ++++++++++++++++++++
src/conf/domain_conf.h | 46 +++++++
src/libvirt_private.syms | 8 ++
src/qemu/qemu_command.c | 12 ++
.../qemuxml2argv-graphics-spice.args | 4 +-
.../qemuxml2argv-graphics-spice.xml | 4 +
8 files changed, 260 insertions(+), 1 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 3c4c656..c5edf53 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -1664,6 +1664,18 @@ qemu-kvm -net nic,model=? /dev/null
<channel name='main' mode='secure'/>
<channel name='record' mode='insecure'/>
</graphics></pre>
+ <p>
+Spice supports variable compression settings for audio, images and streaming.
+This setting are accessible via <code>compression</code> attribute in all
+following elements: <code>image</code> to set image compression (accept
+<code>auto_glz</code>, <code>auto_lz</code>, <code>quic</code>,
+<code>glz</code>, <code>lz</code>, <code>off</code>), <code>jpeg</code> for
+JPEG compression for images over wan (accept <code>auto</code>,
+<code>never</code>, <code>always</code>), <code>zlib</code> for configuring
+wan image compression (accept <code>auto</code>, <code>never</code>,
+<code>always</code>) and <code>playback</code> for enabling audio stream
+compression (accept <code>on</code> or <code>off</code>)
+ </p>
</dd>
<dt><code>"rdp"</code></dt>
<dd>
diff --git a/docs/schemas/domain.rng b/docs/schemas/domain.rng
index 0fbf326..f0578f8 100644
--- a/docs/schemas/domain.rng
+++ b/docs/schemas/domain.rng
@@ -1283,6 +1283,56 @@
<empty/>
</element>
</zeroOrMore>
+ <optional>
+ <element name="image">
+ <attribute name="compression">
+ <choice>
+ <value>auto_glz</value>
+ <value>auto_lz</value>
+ <value>quic</value>
+ <value>glz</value>
+ <value>lz</value>
+ <value>off</value>
+ </choice>
+ </attribute>
+ <empty/>
+ </element>
+ </optional>
+ <optional>
+ <element name="jpeg">
+ <attribute name="compression">
+ <choice>
+ <value>auto</value>
+ <value>never</value>
+ <value>always</value>
+ </choice>
+ </attribute>
+ <empty/>
+ </element>
+ </optional>
+ <optional>
+ <element name="zlib">
+ <attribute name="compression">
+ <choice>
+ <value>auto</value>
+ <value>never</value>
+ <value>always</value>
+ </choice>
+ </attribute>
+ <empty/>
+ </element>
+ </optional>
+ <optional>
+ <element name="playback">
+ <attribute name="compression">
+ <choice>
+ <value>on</value>
+ <value>off</value>
+ </choice>
+ </attribute>
+ <empty/>
+ </element>
+ </optional>
</group>
<group>
<attribute name="type">
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 90a1317..a380db3 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -322,6 +322,36 @@ VIR_ENUM_IMPL(virDomainGraphicsSpiceChannelMode,
"secure",
"insecure");
+VIR_ENUM_IMPL(virDomainGraphicsSpiceImageCompression,
+ VIR_DOMAIN_GRAPHICS_SPICE_IMAGE_COMPRESSION_LAST,
+ "default",
+ "auto_glz",
+ "auto_lz",
+ "quic",
+ "glz",
+ "lz",
+ "off");
+
+VIR_ENUM_IMPL(virDomainGraphicsSpiceJpegCompression,
+ VIR_DOMAIN_GRAPHICS_SPICE_JPEG_COMPRESSION_LAST,
+ "default",
+ "auto",
+ "never",
+ "always");
+
+VIR_ENUM_IMPL(virDomainGraphicsSpiceZlibCompression,
+ VIR_DOMAIN_GRAPHICS_SPICE_ZLIB_COMPRESSION_LAST,
+ "default",
+ "auto",
+ "never",
+ "always");
+
+VIR_ENUM_IMPL(virDomainGraphicsSpicePlaybackCompression,
+ VIR_DOMAIN_GRAPHICS_SPICE_PLAYBACK_COMPRESSION_LAST,
+ "default",
+ "on",
+ "off");
+
VIR_ENUM_IMPL(virDomainHostdevMode, VIR_DOMAIN_HOSTDEV_MODE_LAST,
"subsystem",
"capabilities")
@@ -3954,6 +3984,89 @@ virDomainGraphicsDefParseXML(xmlNodePtr node, int flags) {
VIR_FREE(mode);
def->data.spice.channels[nameval] = modeval;
+ } else if (xmlStrEqual(cur->name, BAD_CAST "image")) {
+ const char *compression = virXMLPropString(cur, "compression");
+ int compressionVal;
+
+ if (!compression) {
+ virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("spice image missing compression"));
+ goto error;
+ }
+
+ if ((compressionVal =
+ virDomainGraphicsSpiceImageCompressionTypeFromString(compression)) < 0) {
+ virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("unknown spice image compression %s"),
+ compression);
+ VIR_FREE(compression);
+ goto error;
+ }
+ VIR_FREE(compression);
+
+ def->data.spice.image = compressionVal;
+ } else if (xmlStrEqual(cur->name, BAD_CAST "jpeg")) {
+ const char *compression = virXMLPropString(cur, "compression");
+ int compressionVal;
+
+ if (!compression) {
+ virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("spice jpeg missing compression"));
+ goto error;
+ }
+
+ if ((compressionVal =
+ virDomainGraphicsSpiceJpegCompressionTypeFromString(compression)) < 0) {
+ virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("unknown spice jpeg compression %s"),
+ compression);
+ VIR_FREE(compression);
+ goto error;
+ }
+ VIR_FREE(compression);
+
+ def->data.spice.jpeg = compressionVal;
+ } else if (xmlStrEqual(cur->name, BAD_CAST "zlib")) {
+ const char *compression = virXMLPropString(cur, "compression");
+ int compressionVal;
+
+ if (!compression) {
+ virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("spice zlib missing compression"));
+ goto error;
+ }
+
+ if ((compressionVal =
+ virDomainGraphicsSpiceZlibCompressionTypeFromString(compression)) < 0) {
+ virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("unknown spice zlib compression %s"),
+ compression);
+ VIR_FREE(compression);
+ goto error;
+ }
+
+ def->data.spice.zlib = compressionVal;
+ } else if (xmlStrEqual(cur->name, BAD_CAST "playback")) {
+ const char *compression = virXMLPropString(cur, "compression");
+ int compressionVal;
+
+ if (!compression) {
+ virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("spice playback missing compression"));
+ goto error;
+ }
+
+ if ((compressionVal =
+ virDomainGraphicsSpicePlaybackCompressionTypeFromString(compression)) < 0) {
+ virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("unknown spice playback compression"));
+ VIR_FREE(compression);
+ goto error;
+
+ }
+ VIR_FREE(compression);
+
+ def->data.spice.playback = compressionVal;
}
}
cur = cur->next;
@@ -7817,6 +7930,18 @@ virDomainGraphicsDefFormat(virBufferPtr buf,
virDomainGraphicsSpiceChannelNameTypeToString(i),
virDomainGraphicsSpiceChannelModeTypeToString(mode));
}
+ if (def->data.spice.image)
+ virBufferVSprintf(buf, " <image compression='%s'/>\n",
+ virDomainGraphicsSpiceImageCompressionTypeToString(def->data.spice.image));
+ if (def->data.spice.jpeg)
+ virBufferVSprintf(buf, " <jpeg compression='%s'/>\n",
+ virDomainGraphicsSpiceJpegCompressionTypeToString(def->data.spice.jpeg));
+ if (def->data.spice.zlib)
+ virBufferVSprintf(buf, " <zlib compression='%s'/>\n",
+ virDomainGraphicsSpiceZlibCompressionTypeToString(def->data.spice.zlib));
+ if (def->data.spice.playback)
+ virBufferVSprintf(buf, " <playback compression='%s'/>\n",
+ virDomainGraphicsSpicePlaybackCompressionTypeToString(def->data.spice.playback));
}
if (children) {
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 95bd11e..60a33ce 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -658,6 +658,44 @@ enum virDomainGraphicsSpiceChannelMode {
VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_MODE_LAST
};
+enum virDomainGraphicsSpiceImageCompression {
+ VIR_DOMAIN_GRAPHICS_SPICE_IMAGE_COMPRESSION_DEFAULT = 0,
+ VIR_DOMAIN_GRAPHICS_SPICE_IMAGE_COMPRESSION_AUTO_GLZ,
+ VIR_DOMAIN_GRAPHICS_SPICE_IMAGE_COMPRESSION_AUTO_LZ,
+ VIR_DOMAIN_GRAPHICS_SPICE_IMAGE_COMPRESSION_QUIC,
+ VIR_DOMAIN_GRAPHICS_SPICE_IMAGE_COMPRESSION_GLZ,
+ VIR_DOMAIN_GRAPHICS_SPICE_IMAGE_COMPRESSION_LZ,
+ VIR_DOMAIN_GRAPHICS_SPICE_IMAGE_COMPRESSION_OFF,
+
+ VIR_DOMAIN_GRAPHICS_SPICE_IMAGE_COMPRESSION_LAST
+};
+
+enum virDomainGraphicsSpiceJpegCompression {
+ VIR_DOMAIN_GRAPHICS_SPICE_JPEG_COMPRESSION_DEFAULT = 0,
+ VIR_DOMAIN_GRAPHICS_SPICE_JPEG_COMPRESSION_AUTO,
+ VIR_DOMAIN_GRAPHICS_SPICE_JPEG_COMPRESSION_NEVER,
+ VIR_DOMAIN_GRAPHICS_SPICE_JPEG_COMPRESSION_ALWAYS,
+
+ VIR_DOMAIN_GRAPHICS_SPICE_JPEG_COMPRESSION_LAST
+};
+
+enum virDomainGraphicsSpiceZlibCompression {
+ VIR_DOMAIN_GRAPHICS_SPICE_ZLIB_COMPRESSION_DEFAULT = 0,
+ VIR_DOMAIN_GRAPHICS_SPICE_ZLIB_COMPRESSION_AUTO,
+ VIR_DOMAIN_GRAPHICS_SPICE_ZLIB_COMPRESSION_NEVER,
+ VIR_DOMAIN_GRAPHICS_SPICE_ZLIB_COMPRESSION_ALWAYS,
+
+ VIR_DOMAIN_GRAPHICS_SPICE_ZLIB_COMPRESSION_LAST
+};
+
+enum virDomainGraphicsSpicePlaybackCompression {
+ VIR_DOMAIN_GRAPHICS_SPICE_PLAYBACK_COMPRESSION_DEFAULT = 0,
+ VIR_DOMAIN_GRAPHICS_SPICE_PLAYBACK_COMPRESSION_ON,
+ VIR_DOMAIN_GRAPHICS_SPICE_PLAYBACK_COMPRESSION_OFF,
+
+ VIR_DOMAIN_GRAPHICS_SPICE_PLAYBACK_COMPRESSION_LAST
+};
+
typedef struct _virDomainGraphicsDef virDomainGraphicsDef;
typedef virDomainGraphicsDef *virDomainGraphicsDefPtr;
struct _virDomainGraphicsDef {
@@ -695,6 +733,10 @@ struct _virDomainGraphicsDef {
virDomainGraphicsAuthDef auth;
unsigned int autoport :1;
int channels[VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_LAST];
+ int image;
+ int jpeg;
+ int zlib;
+ int playback;
} spice;
} data;
};
@@ -1423,6 +1465,10 @@ VIR_ENUM_DECL(virDomainInputBus)
VIR_ENUM_DECL(virDomainGraphics)
VIR_ENUM_DECL(virDomainGraphicsSpiceChannelName)
VIR_ENUM_DECL(virDomainGraphicsSpiceChannelMode)
+VIR_ENUM_DECL(virDomainGraphicsSpiceImageCompression)
+VIR_ENUM_DECL(virDomainGraphicsSpiceJpegCompression)
+VIR_ENUM_DECL(virDomainGraphicsSpiceZlibCompression)
+VIR_ENUM_DECL(virDomainGraphicsSpicePlaybackCompression)
/* from libvirt.h */
VIR_ENUM_DECL(virDomainState)
VIR_ENUM_DECL(virDomainSeclabel)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 54e4482..d2aa077 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -262,6 +262,14 @@ virDomainGraphicsSpiceChannelModeTypeFromString;
virDomainGraphicsSpiceChannelModeTypeToString;
virDomainGraphicsSpiceChannelNameTypeFromString;
virDomainGraphicsSpiceChannelNameTypeToString;
+virDomainGraphicsSpiceImageCompressionTypeToString;
+virDomainGraphicsSpiceImageCompressionTypeFromString;
+virDomainGraphicsSpiceJpegCompressionTypeFromString;
+virDomainGraphicsSpiceJpegCompressionTypeToString;
+virDomainGraphicsSpicePlaybackCompressionTypeFromString;
+virDomainGraphicsSpicePlaybackCompressionTypeToString;
+virDomainGraphicsSpiceZlibCompressionTypeFromString;
+virDomainGraphicsSpiceZlibCompressionTypeToString;
virDomainGraphicsTypeFromString;
virDomainGraphicsTypeToString;
virDomainHostdevDefFree;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index fea0068..89668d4 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -4032,6 +4032,18 @@ qemuBuildCommandLine(virConnectPtr conn,
break;
}
}
+ if (def->graphics[0]->data.spice.image)
+ virBufferVSprintf(&opt, ",image-compression=%s",
+ virDomainGraphicsSpiceImageCompressionTypeToString(def->graphics[0]->data.spice.image));
+ if (def->graphics[0]->data.spice.jpeg)
+ virBufferVSprintf(&opt, ",jpeg-wan-compression=%s",
+ virDomainGraphicsSpiceJpegCompressionTypeToString(def->graphics[0]->data.spice.jpeg));
+ if (def->graphics[0]->data.spice.zlib)
+ virBufferVSprintf(&opt, ",zlib-glz-wan-compression=%s",
+ virDomainGraphicsSpiceZlibCompressionTypeToString(def->graphics[0]->data.spice.zlib));
+ if (def->graphics[0]->data.spice.playback)
+ virBufferVSprintf(&opt, ",playback-compression=%s",
+ virDomainGraphicsSpicePlaybackCompressionTypeToString(def->graphics[0]->data.spice.playback));
virCommandAddArg(cmd, "-spice");
virCommandAddArgBuffer(cmd, &opt);
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice.args b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice.args
index c788bb6..70cd35b 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice.args
@@ -2,6 +2,8 @@ LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=spice \
/usr/bin/qemu -S -M pc -m 214 -smp 1 -nodefaults -monitor \
unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -hda \
/dev/HostVG/QEMUGuest1 -usb -spice port=5903,tls-port=5904,addr=127.0.0.1,\
-x509-dir=/etc/pki/libvirt-spice,tls-channel=main,plaintext-channel=inputs -vga \
+x509-dir=/etc/pki/libvirt-spice,tls-channel=main,plaintext-channel=inputs,\
+image-compression=auto_glz,jpeg-wan-compression=auto,zlib-glz-wan-compression=auto,\
+playback-compression=on -vga \
qxl -global qxl.vram_size=18874368 -device qxl,id=video1,vram_size=33554432,bus=pci.0,addr=0x4 \
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice.xml b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice.xml
index 5d46509..a29f50d 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice.xml
@@ -24,6 +24,10 @@
<graphics type='spice' port='5903' tlsPort='5904' autoport='no' listen='127.0.0.1'>
<channel name='main' mode='secure'/>
<channel name='inputs' mode='insecure'/>
+ <image compression='auto_glz'/>
+ <jpeg compression='auto'/>
+ <zlib compression='auto'/>
+ <playback compression='on'/>
</graphics>
<video>
<model type='qxl' vram='18432' heads='1'/>
--
1.7.4.2
13 years, 7 months
[libvirt] [libvirt PATCH v2] Introduce virDomainChrDefNew()
by Michal Novotny
Make: passed
Make check: passed
Make syntax-check: passed
Hi,
this is the commit to introduce the function to create new character
device definition for the domain as advised by Cole Robinson
<crobinso(a)redhat.com>.
The function is used on the relevant places and also new tests has
been added.
Michal
Signed-off-by: Michal Novotny <minovotn(a)redhat.com>
---
src/conf/domain_conf.c | 20 +++++++++--
src/conf/domain_conf.h | 2 +
src/libvirt_private.syms | 1 +
src/qemu/qemu_command.c | 3 +-
src/xenxs/xen_sxpr.c | 5 ++-
src/xenxs/xen_xm.c | 6 +++-
.../qemuxml2argv-multiple-serials.xml | 31 ++++++++++++++++
.../qemuxml2xmlout-multiple-serials.xml | 37 ++++++++++++++++++++
tests/qemuxml2xmltest.c | 1 +
9 files changed, 100 insertions(+), 6 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-multiple-serials.xml
create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-multiple-serials.xml
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 90a1317..a80719c 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -3212,6 +3212,22 @@ error:
goto cleanup;
}
+/* Create a new character device definition and set
+ * default port.
+ */
+virDomainChrDefPtr
+virDomainChrDefNew(void) {
+ virDomainChrDefPtr def = NULL;
+
+ if (VIR_ALLOC(def) < 0) {
+ virReportOOMError();
+ return NULL;
+ }
+
+ def->target.port = -1;
+ return def;
+}
+
/* Parse the XML definition for a character device
* @param node XML nodeset to parse for net definition
*
@@ -3260,10 +3276,8 @@ virDomainChrDefParseXML(virCapsPtr caps,
virDomainChrDefPtr def;
int remaining;
- if (VIR_ALLOC(def) < 0) {
- virReportOOMError();
+ if (!(def = virDomainChrDefNew()))
return NULL;
- }
type = virXMLPropString(node, "type");
if (type == NULL) {
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 95bd11e..ecf44ca 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1229,6 +1229,8 @@ void virDomainObjRef(virDomainObjPtr vm);
/* Returns 1 if the object was freed, 0 if more refs exist */
int virDomainObjUnref(virDomainObjPtr vm) ATTRIBUTE_RETURN_CHECK;
+virDomainChrDefPtr virDomainChrDefNew(void);
+
/* live == true means def describes an active domain (being migrated or
* restored) as opposed to a new persistent configuration of the domain */
virDomainObjPtr virDomainAssignDef(virCapsPtr caps,
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 54e4482..4175ca0 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -201,6 +201,7 @@ virDomainChrConsoleTargetTypeFromString;
virDomainChrConsoleTargetTypeToString;
virDomainChrDefForeach;
virDomainChrDefFree;
+virDomainChrDefNew;
virDomainChrSourceDefFree;
virDomainChrSpicevmcTypeFromString;
virDomainChrSpicevmcTypeToString;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index fea0068..d258712 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -36,6 +36,7 @@
#include "c-ctype.h"
#include "domain_nwfilter.h"
#include "qemu_audit.h"
+#include "domain_conf.h"
#include <sys/utsname.h>
#include <sys/stat.h>
@@ -5315,7 +5316,7 @@ qemuParseCommandLineChr(const char *val)
{
virDomainChrDefPtr def;
- if (VIR_ALLOC(def) < 0)
+ if (!(def = virDomainChrDefNew()))
goto no_memory;
if (STREQ(val, "null")) {
diff --git a/src/xenxs/xen_sxpr.c b/src/xenxs/xen_sxpr.c
index 3a412a6..d1a0b0e 100644
--- a/src/xenxs/xen_sxpr.c
+++ b/src/xenxs/xen_sxpr.c
@@ -168,7 +168,7 @@ xenParseSxprChar(const char *value,
char *tmp;
virDomainChrDefPtr def;
- if (VIR_ALLOC(def) < 0) {
+ if (!(def = virDomainChrDefNew())) {
virReportOOMError();
return NULL;
}
@@ -1328,6 +1328,7 @@ xenParseSxpr(const struct sexpr *root,
goto no_memory;
}
chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL;
+ chr->target.port = 0;
def->serials[def->nserials++] = chr;
}
}
@@ -1343,6 +1344,7 @@ xenParseSxpr(const struct sexpr *root,
goto no_memory;
}
chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL;
+ chr->target.port = 0;
def->parallels[def->nparallels++] = chr;
}
} else {
@@ -1350,6 +1352,7 @@ xenParseSxpr(const struct sexpr *root,
if (!(def->console = xenParseSxprChar("pty", tty)))
goto error;
def->console->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE;
+ def->console->target.port = 0;
def->console->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN;
}
VIR_FREE(tty);
diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
index 22ad788..22d84dd 100644
--- a/src/xenxs/xen_xm.c
+++ b/src/xenxs/xen_xm.c
@@ -36,6 +36,7 @@
#include "xenxs_private.h"
#include "xen_xm.h"
#include "xen_sxpr.h"
+#include "domain_conf.h"
/* Convenience method to grab a int from the config file object */
static int xenXMConfigGetBool(virConfPtr conf,
@@ -957,6 +958,7 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
goto no_memory;
}
chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL;
+ chr->target.port = 0;
def->parallels[0] = chr;
def->nparallels++;
chr = NULL;
@@ -981,7 +983,7 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
continue;
}
- if (VIR_ALLOC(chr) < 0)
+ if (!(chr = virDomainChrDefNew()))
goto no_memory;
if (!(chr = xenParseSxprChar(port, NULL)))
goto cleanup;
@@ -1010,6 +1012,7 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
goto no_memory;
}
chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL;
+ chr->target.port = 0;
def->serials[0] = chr;
def->nserials++;
}
@@ -1018,6 +1021,7 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
if (!(def->console = xenParseSxprChar("pty", NULL)))
goto cleanup;
def->console->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE;
+ def->console->target.port= 0;
def->console->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN;
}
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-multiple-serials.xml b/tests/qemuxml2argvdata/qemuxml2argv-multiple-serials.xml
new file mode 100644
index 0000000..0f98f51
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-multiple-serials.xml
@@ -0,0 +1,31 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory>219100</memory>
+ <currentMemory>219100</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='disk'>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0' unit='0'/>
+ </disk>
+ <controller type='ide' index='0'/>
+ <serial type='pty'/>
+ <serial type='null'/>
+ <serial type='stdio'/>
+ <console type='pty'>
+ <target port='0'/>
+ </console>
+ <memballoon model='virtio'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-multiple-serials.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-multiple-serials.xml
new file mode 100644
index 0000000..878418a
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-multiple-serials.xml
@@ -0,0 +1,37 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory>219100</memory>
+ <currentMemory>219100</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='disk'>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0' unit='0'/>
+ </disk>
+ <controller type='ide' index='0'/>
+ <serial type='pty'>
+ <target port='0'/>
+ </serial>
+ <serial type='null'>
+ <target port='1'/>
+ </serial>
+ <serial type='stdio'>
+ <target port='2'/>
+ </serial>
+ <console type='pty'>
+ <target type='serial' port='0'/>
+ </console>
+ <memballoon model='virtio'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index b86dbee..dbc3279 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -195,6 +195,7 @@ mymain(int argc, char **argv)
DO_TEST_DIFFERENT("console-compat-auto");
DO_TEST_DIFFERENT("disk-scsi-device-auto");
DO_TEST_DIFFERENT("console-virtio");
+ DO_TEST_DIFFERENT("multiple-serials");
virCapabilitiesFree(driver.caps);
--
1.7.3.2
13 years, 7 months
[libvirt] [PATCH] free cpumask of vcpupinDef
by Hu Tao
cpumask doesn't get freed when vcpupinDef being freed, this leaks
memory.
---
src/conf/domain_conf.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 1de4c7a..7b6b044 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -858,6 +858,7 @@ virDomainVcpupinDefFree(virDomainVcpupinDefPtr *def,
return;
for(i = 0; i < nvcpupin; i++) {
+ VIR_FREE(def[i]->cpumask);
VIR_FREE(def[i]);
}
--
1.7.3.1
13 years, 7 months