[libvirt] [PATCH go-xml] Add support for memory device element
by zhenwei.pi
Support model, access and target.
Add Marshal/Unmarshal mothed for memory device.
Add test code for device list in full domain.
Signed-off-by: zhenwei.pi <zhenwei.pi(a)youruncloud.com>
---
domain.go | 29 +++++++++++++++++++++++++++++
domain_test.go | 45 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 74 insertions(+)
diff --git a/domain.go b/domain.go
index 8c2cc1b..bacab11 100644
--- a/domain.go
+++ b/domain.go
@@ -436,6 +436,22 @@ type DomainHostdev struct {
Address *DomainAddress `xml:"address"`
}
+type DomainMemorydevTargetNode struct {
+ Value uint `xml:",chardata"`
+}
+
+type DomainMemorydevTarget struct {
+ Size *DomainMemory `xml:"size"`
+ Node *DomainMemorydevTargetNode `xml:"node"`
+}
+
+type DomainMemorydev struct {
+ XMLName xml.Name `xml:"memory"`
+ Model string `xml:"model,attr"`
+ Access string `xml:"access,attr"`
+ Target *DomainMemorydevTarget `xml:"target"`
+}
+
type DomainDeviceList struct {
Emulator string `xml:"emulator,omitempty"`
Controllers []DomainController `xml:"controller"`
@@ -452,6 +468,7 @@ type DomainDeviceList struct {
Sounds []DomainSound `xml:"sound"`
RNGs []DomainRNG `xml:"rng"`
Hostdevs []DomainHostdev `xml:"hostdev"`
+ Memorydevs []DomainMemorydev `xml:"memory"`
}
type DomainMemory struct {
@@ -915,6 +932,18 @@ func (d *DomainHostdev) Marshal() (string, error) {
return string(doc), nil
}
+func (d *DomainMemorydev) Unmarshal(doc string) error {
+ return xml.Unmarshal([]byte(doc), d)
+}
+
+func (d *DomainMemorydev) Marshal() (string, error) {
+ doc, err := xml.MarshalIndent(d, "", " ")
+ if err != nil {
+ return "", err
+ }
+ return string(doc), nil
+}
+
type HexUint uint
func (h *HexUint) UnmarshalXMLAttr(attr xml.Attr) error {
diff --git a/domain_test.go b/domain_test.go
index 4fe6bfe..dbebe42 100644
--- a/domain_test.go
+++ b/domain_test.go
@@ -372,6 +372,21 @@ var domainTestData = []struct {
},
},
},
+ Memorydevs: []DomainMemorydev{
+ DomainMemorydev{
+ Model: "dimm",
+ Access: "private",
+ Target: &DomainMemorydevTarget{
+ Size: &DomainMemory{
+ Value: 1,
+ Unit: "GiB",
+ },
+ Node: &DomainMemorydevTargetNode{
+ Value: 0,
+ },
+ },
+ },
+ },
},
},
Expected: []string{
@@ -414,6 +429,12 @@ var domainTestData = []struct {
` <source mode="connect" service="1234" host="1.2.3.4"></source>`,
` </backend>`,
` </rng>`,
+ ` <memory model="dimm" access="private">`,
+ ` <target>`,
+ ` <size unit="GiB">1</size>`,
+ ` <node>0</node>`,
+ ` </target>`,
+ ` </memory>`,
` </devices>`,
`</domain>`,
},
@@ -1630,6 +1651,30 @@ var domainTestData = []struct {
`</hostdev>`,
},
},
+ {
+ Object: &DomainMemorydev{
+ Model: "dimm",
+ Access: "private",
+ Target: &DomainMemorydevTarget{
+ Size: &DomainMemory{
+ Value: 1,
+ Unit: "GiB",
+ },
+ Node: &DomainMemorydevTargetNode{
+ Value: 0,
+ },
+ },
+ },
+
+ Expected: []string{
+ `<memory model="dimm" access="private">`,
+ ` <target>`,
+ ` <size unit="GiB">1</size>`,
+ ` <node>0</node>`,
+ ` </target>`,
+ `</memory>`,
+ },
+ },
}
func TestDomain(t *testing.T) {
--
2.7.4
7 years, 2 months
[libvirt] [PATCH v2] qemu: Don't crash when parsing command line lacking -M
by Andrea Bolognani
Parse the -M (or -machine) command line option before starting
processing in earnest and have a fallback ready in case it's not
present, so that while parsing other options we can rely on
def->os.machine being initialized.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1379218
Signed-off-by: Andrea Bolognani <abologna(a)redhat.com>
---
Changes from [v1]:
* rework command line parsing instead of adding checks to
qemuDomainMachineIs*() functions
[v1] https://www.redhat.com/archives/libvir-list/2017-October/msg00406.html
src/qemu/qemu_parse_command.c | 174 ++++++++++++---------
.../qemuargv2xml-nomachine-aarch64.args | 11 ++
.../qemuargv2xml-nomachine-aarch64.xml | 39 +++++
.../qemuargv2xml-nomachine-ppc64.args | 11 ++
.../qemuargv2xml-nomachine-ppc64.xml | 49 ++++++
.../qemuargv2xml-nomachine-x86_64.args | 11 ++
.../qemuargv2xml-nomachine-x86_64.xml | 48 ++++++
tests/qemuargv2xmltest.c | 4 +
8 files changed, 270 insertions(+), 77 deletions(-)
create mode 100644 tests/qemuargv2xmldata/qemuargv2xml-nomachine-aarch64.args
create mode 100644 tests/qemuargv2xmldata/qemuargv2xml-nomachine-aarch64.xml
create mode 100644 tests/qemuargv2xmldata/qemuargv2xml-nomachine-ppc64.args
create mode 100644 tests/qemuargv2xmldata/qemuargv2xml-nomachine-ppc64.xml
create mode 100644 tests/qemuargv2xmldata/qemuargv2xml-nomachine-x86_64.args
create mode 100644 tests/qemuargv2xmldata/qemuargv2xml-nomachine-x86_64.xml
diff --git a/src/qemu/qemu_parse_command.c b/src/qemu/qemu_parse_command.c
index 7c409b03a..aaa4d3703 100644
--- a/src/qemu/qemu_parse_command.c
+++ b/src/qemu/qemu_parse_command.c
@@ -1884,6 +1884,98 @@ qemuParseCommandLine(virCapsPtr caps,
}
}
+ /* Detect machine type before processing any other arguments,
+ * because they might depend on it */
+ for (i = 1; progargv[i]; i++) {
+ const char *arg = progargv[i];
+
+ /* Make sure we have a single - for all options to
+ simplify next logic */
+ if (STRPREFIX(arg, "--"))
+ arg++;
+
+ if (STREQ(arg, "-M") ||
+ STREQ(arg, "-machine")) {
+ char *param;
+ size_t j = 0;
+
+ /* -machine [type=]name[,prop[=value][,...]]
+ * Set os.machine only if first parameter lacks '=' or
+ * contains explicit type='...' */
+ WANT_VALUE();
+ if (!(list = virStringSplit(val, ",", 0)))
+ goto error;
+ param = list[0];
+
+ if (STRPREFIX(param, "type="))
+ param += strlen("type=");
+ if (!strchr(param, '=')) {
+ if (VIR_STRDUP(def->os.machine, param) < 0)
+ goto error;
+ j++;
+ }
+
+ /* handle all remaining "-machine" parameters */
+ while ((param = list[j++])) {
+ if (STRPREFIX(param, "dump-guest-core=")) {
+ param += strlen("dump-guest-core=");
+ def->mem.dump_core = virTristateSwitchTypeFromString(param);
+ if (def->mem.dump_core <= 0)
+ def->mem.dump_core = VIR_TRISTATE_SWITCH_ABSENT;
+ } else if (STRPREFIX(param, "mem-merge=off")) {
+ def->mem.nosharepages = true;
+ } else if (STRPREFIX(param, "accel=kvm")) {
+ def->virtType = VIR_DOMAIN_VIRT_KVM;
+ def->features[VIR_DOMAIN_FEATURE_PAE] = VIR_TRISTATE_SWITCH_ON;
+ } else if (STRPREFIX(param, "aes-key-wrap=")) {
+ if (STREQ(arg, "-M")) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("aes-key-wrap is not supported with "
+ "this QEMU binary"));
+ goto error;
+ }
+ param += strlen("aes-key-wrap=");
+ if (!def->keywrap && VIR_ALLOC(def->keywrap) < 0)
+ goto error;
+ def->keywrap->aes = virTristateSwitchTypeFromString(param);
+ if (def->keywrap->aes < 0)
+ def->keywrap->aes = VIR_TRISTATE_SWITCH_ABSENT;
+ } else if (STRPREFIX(param, "dea-key-wrap=")) {
+ if (STREQ(arg, "-M")) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("dea-key-wrap is not supported with "
+ "this QEMU binary"));
+ goto error;
+ }
+ param += strlen("dea-key-wrap=");
+ if (!def->keywrap && VIR_ALLOC(def->keywrap) < 0)
+ goto error;
+ def->keywrap->dea = virTristateSwitchTypeFromString(param);
+ if (def->keywrap->dea < 0)
+ def->keywrap->dea = VIR_TRISTATE_SWITCH_ABSENT;
+ }
+ }
+ virStringListFree(list);
+ list = NULL;
+ }
+ }
+
+ /* If no machine type has been found among the arguments, then figure
+ * out a reasonable value by using capabilities */
+ if (!def->os.machine) {
+ virCapsDomainDataPtr capsdata;
+
+ if (!(capsdata = virCapabilitiesDomainDataLookup(caps, def->os.type,
+ def->os.arch, def->virtType, NULL, NULL)))
+ goto error;
+
+ if (VIR_STRDUP(def->os.machine, capsdata->machinetype) < 0) {
+ VIR_FREE(capsdata);
+ goto error;
+ }
+ VIR_FREE(capsdata);
+ }
+
/* Now the real processing loop */
for (i = 1; progargv[i]; i++) {
const char *arg = progargv[i];
@@ -2137,69 +2229,6 @@ qemuParseCommandLine(virCapsPtr caps,
}
if (STREQ(def->name, ""))
VIR_FREE(def->name);
- } else if (STREQ(arg, "-M") ||
- STREQ(arg, "-machine")) {
- char *param;
- size_t j = 0;
-
- /* -machine [type=]name[,prop[=value][,...]]
- * Set os.machine only if first parameter lacks '=' or
- * contains explicit type='...' */
- WANT_VALUE();
- if (!(list = virStringSplit(val, ",", 0)))
- goto error;
- param = list[0];
-
- if (STRPREFIX(param, "type="))
- param += strlen("type=");
- if (!strchr(param, '=')) {
- if (VIR_STRDUP(def->os.machine, param) < 0)
- goto error;
- j++;
- }
-
- /* handle all remaining "-machine" parameters */
- while ((param = list[j++])) {
- if (STRPREFIX(param, "dump-guest-core=")) {
- param += strlen("dump-guest-core=");
- def->mem.dump_core = virTristateSwitchTypeFromString(param);
- if (def->mem.dump_core <= 0)
- def->mem.dump_core = VIR_TRISTATE_SWITCH_ABSENT;
- } else if (STRPREFIX(param, "mem-merge=off")) {
- def->mem.nosharepages = true;
- } else if (STRPREFIX(param, "accel=kvm")) {
- def->virtType = VIR_DOMAIN_VIRT_KVM;
- def->features[VIR_DOMAIN_FEATURE_PAE] = VIR_TRISTATE_SWITCH_ON;
- } else if (STRPREFIX(param, "aes-key-wrap=")) {
- if (STREQ(arg, "-M")) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("aes-key-wrap is not supported with "
- "this QEMU binary"));
- goto error;
- }
- param += strlen("aes-key-wrap=");
- if (!def->keywrap && VIR_ALLOC(def->keywrap) < 0)
- goto error;
- def->keywrap->aes = virTristateSwitchTypeFromString(param);
- if (def->keywrap->aes < 0)
- def->keywrap->aes = VIR_TRISTATE_SWITCH_ABSENT;
- } else if (STRPREFIX(param, "dea-key-wrap=")) {
- if (STREQ(arg, "-M")) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("dea-key-wrap is not supported with "
- "this QEMU binary"));
- goto error;
- }
- param += strlen("dea-key-wrap=");
- if (!def->keywrap && VIR_ALLOC(def->keywrap) < 0)
- goto error;
- def->keywrap->dea = virTristateSwitchTypeFromString(param);
- if (def->keywrap->dea < 0)
- def->keywrap->dea = VIR_TRISTATE_SWITCH_ABSENT;
- }
- }
- virStringListFree(list);
- list = NULL;
} else if (STREQ(arg, "-serial")) {
WANT_VALUE();
if (STRNEQ(val, "none")) {
@@ -2489,6 +2518,11 @@ qemuParseCommandLine(virCapsPtr caps,
argRecognized = false;
}
+ } else if (STREQ(arg, "-M") ||
+ STREQ(arg, "-machine")) {
+ // This option has already been processed before entering this
+ // loop, so we just need to skip its argument and move along
+ WANT_VALUE();
} else {
argRecognized = false;
}
@@ -2571,20 +2605,6 @@ qemuParseCommandLine(virCapsPtr caps,
}
}
- if (!def->os.machine) {
- virCapsDomainDataPtr capsdata;
-
- if (!(capsdata = virCapabilitiesDomainDataLookup(caps, def->os.type,
- def->os.arch, def->virtType, NULL, NULL)))
- goto error;
-
- if (VIR_STRDUP(def->os.machine, capsdata->machinetype) < 0) {
- VIR_FREE(capsdata);
- goto error;
- }
- VIR_FREE(capsdata);
- }
-
if (!nographics && (def->ngraphics == 0 || have_sdl)) {
virDomainGraphicsDefPtr sdl;
const char *display = qemuFindEnv(progenv, "DISPLAY");
diff --git a/tests/qemuargv2xmldata/qemuargv2xml-nomachine-aarch64.args b/tests/qemuargv2xmldata/qemuargv2xml-nomachine-aarch64.args
new file mode 100644
index 000000000..b17c0d0c2
--- /dev/null
+++ b/tests/qemuargv2xmldata/qemuargv2xml-nomachine-aarch64.args
@@ -0,0 +1,11 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-aarch64 \
+-name QEMUGuest1 \
+-m 512 \
+-hda /dev/HostVG/QEMUGuest1 \
+-cdrom /root/boot.iso
diff --git a/tests/qemuargv2xmldata/qemuargv2xml-nomachine-aarch64.xml b/tests/qemuargv2xmldata/qemuargv2xml-nomachine-aarch64.xml
new file mode 100644
index 000000000..eb8f9db80
--- /dev/null
+++ b/tests/qemuargv2xmldata/qemuargv2xml-nomachine-aarch64.xml
@@ -0,0 +1,39 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>524288</memory>
+ <currentMemory unit='KiB'>524288</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='aarch64' machine='virt'>hvm</type>
+ </os>
+ <features>
+ <gic version='2'/>
+ </features>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-aarch64</emulator>
+ <disk type='block' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+ </disk>
+ <disk type='file' device='cdrom'>
+ <driver name='qemu' type='raw'/>
+ <source file='/root/boot.iso'/>
+ <target dev='hdc' bus='ide'/>
+ <readonly/>
+ <address type='drive' controller='0' bus='1' target='0' unit='0'/>
+ </disk>
+ <controller type='ide' index='0'/>
+ <graphics type='sdl'/>
+ <video>
+ <model type='cirrus' vram='16384' heads='1' primary='yes'/>
+ </video>
+ <memballoon model='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuargv2xmldata/qemuargv2xml-nomachine-ppc64.args b/tests/qemuargv2xmldata/qemuargv2xml-nomachine-ppc64.args
new file mode 100644
index 000000000..ac618775e
--- /dev/null
+++ b/tests/qemuargv2xmldata/qemuargv2xml-nomachine-ppc64.args
@@ -0,0 +1,11 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-ppc64 \
+-name QEMUGuest1 \
+-m 512 \
+-hda /dev/HostVG/QEMUGuest1 \
+-cdrom /root/boot.iso
diff --git a/tests/qemuargv2xmldata/qemuargv2xml-nomachine-ppc64.xml b/tests/qemuargv2xmldata/qemuargv2xml-nomachine-ppc64.xml
new file mode 100644
index 000000000..fa41070cb
--- /dev/null
+++ b/tests/qemuargv2xmldata/qemuargv2xml-nomachine-ppc64.xml
@@ -0,0 +1,49 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>524288</memory>
+ <currentMemory unit='KiB'>524288</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='ppc64' machine='pseries'>hvm</type>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-ppc64</emulator>
+ <disk type='block' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='scsi'/>
+ <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+ </disk>
+ <disk type='file' device='cdrom'>
+ <driver name='qemu' type='raw'/>
+ <source file='/root/boot.iso'/>
+ <target dev='hdc' bus='scsi'/>
+ <readonly/>
+ <address type='drive' controller='0' bus='0' target='0' unit='2'/>
+ </disk>
+ <controller type='usb' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
+ </controller>
+ <controller type='pci' index='0' model='pci-root'>
+ <model name='spapr-pci-host-bridge'/>
+ <target index='0'/>
+ </controller>
+ <controller type='scsi' index='0'>
+ <address type='spapr-vio' reg='0x2000'/>
+ </controller>
+ <input type='keyboard' bus='usb'/>
+ <input type='mouse' bus='usb'/>
+ <graphics type='sdl'/>
+ <video>
+ <model type='cirrus' vram='16384' heads='1' primary='yes'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
+ </video>
+ <memballoon model='none'/>
+ <panic model='pseries'/>
+ </devices>
+</domain>
diff --git a/tests/qemuargv2xmldata/qemuargv2xml-nomachine-x86_64.args b/tests/qemuargv2xmldata/qemuargv2xml-nomachine-x86_64.args
new file mode 100644
index 000000000..22bc4fb1c
--- /dev/null
+++ b/tests/qemuargv2xmldata/qemuargv2xml-nomachine-x86_64.args
@@ -0,0 +1,11 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-x86_64 \
+-name QEMUGuest1 \
+-m 512 \
+-hda /dev/HostVG/QEMUGuest1 \
+-cdrom /root/boot.iso
diff --git a/tests/qemuargv2xmldata/qemuargv2xml-nomachine-x86_64.xml b/tests/qemuargv2xmldata/qemuargv2xml-nomachine-x86_64.xml
new file mode 100644
index 000000000..71a36f083
--- /dev/null
+++ b/tests/qemuargv2xmldata/qemuargv2xml-nomachine-x86_64.xml
@@ -0,0 +1,48 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>524288</memory>
+ <currentMemory unit='KiB'>524288</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='x86_64' machine='pc-0.11'>hvm</type>
+ </os>
+ <features>
+ <acpi/>
+ </features>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-x86_64</emulator>
+ <disk type='block' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+ </disk>
+ <disk type='file' device='cdrom'>
+ <driver name='qemu' type='raw'/>
+ <source file='/root/boot.iso'/>
+ <target dev='hdc' bus='ide'/>
+ <readonly/>
+ <address type='drive' controller='0' bus='1' target='0' unit='0'/>
+ </disk>
+ <controller type='usb' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
+ </controller>
+ <controller type='pci' index='0' model='pci-root'/>
+ <controller type='ide' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
+ </controller>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <graphics type='sdl'/>
+ <video>
+ <model type='cirrus' vram='16384' heads='1' primary='yes'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
+ </video>
+ <memballoon model='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuargv2xmltest.c b/tests/qemuargv2xmltest.c
index 1adbcfef6..5d261afa6 100644
--- a/tests/qemuargv2xmltest.c
+++ b/tests/qemuargv2xmltest.c
@@ -288,6 +288,10 @@ mymain(void)
DO_TEST("machine-deakeywrap-off-argv");
DO_TEST("machine-keywrap-none-argv");
+ DO_TEST("nomachine-x86_64");
+ DO_TEST("nomachine-aarch64");
+ DO_TEST("nomachine-ppc64");
+
qemuTestDriverFree(&driver);
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
--
2.13.6
7 years, 2 months
[libvirt] [PATCH] qemu: Avoid crashes in qemuDomainMachineIs*()
by Andrea Bolognani
Make sure pointers are non-NULL before dereferencing them, and
add test suite coverage for the crashers doing so fixes.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1379218
Signed-off-by: Andrea Bolognani <abologna(a)redhat.com>
---
src/qemu/qemu_domain.c | 35 ++++++++--------
.../qemuargv2xml-nomachine-aarch64.args | 11 +++++
.../qemuargv2xml-nomachine-aarch64.xml | 39 ++++++++++++++++++
.../qemuargv2xml-nomachine-ppc64.args | 11 +++++
.../qemuargv2xml-nomachine-ppc64.xml | 47 +++++++++++++++++++++
.../qemuargv2xml-nomachine-x86_64.args | 11 +++++
.../qemuargv2xml-nomachine-x86_64.xml | 48 ++++++++++++++++++++++
tests/qemuargv2xmltest.c | 4 ++
8 files changed, 188 insertions(+), 18 deletions(-)
create mode 100644 tests/qemuargv2xmldata/qemuargv2xml-nomachine-aarch64.args
create mode 100644 tests/qemuargv2xmldata/qemuargv2xml-nomachine-aarch64.xml
create mode 100644 tests/qemuargv2xmldata/qemuargv2xml-nomachine-ppc64.args
create mode 100644 tests/qemuargv2xmldata/qemuargv2xml-nomachine-ppc64.xml
create mode 100644 tests/qemuargv2xmldata/qemuargv2xml-nomachine-x86_64.args
create mode 100644 tests/qemuargv2xmldata/qemuargv2xml-nomachine-x86_64.xml
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index b202d02f9..30ea3e592 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -6601,8 +6601,9 @@ qemuDomainIsQ35(const virDomainDef *def)
bool
qemuDomainMachineIsQ35(const char *machine)
{
- return (STRPREFIX(machine, "pc-q35") ||
- STREQ(machine, "q35"));
+ return (machine &&
+ (STREQ(machine, "q35") ||
+ STRPREFIX(machine, "pc-q35")));
}
@@ -6616,11 +6617,12 @@ qemuDomainIsI440FX(const virDomainDef *def)
bool
qemuDomainMachineIsI440FX(const char *machine)
{
- return (STREQ(machine, "pc") ||
- STRPREFIX(machine, "pc-0.") ||
- STRPREFIX(machine, "pc-1.") ||
- STRPREFIX(machine, "pc-i440") ||
- STRPREFIX(machine, "rhel"));
+ return (machine &&
+ (STREQ(machine, "pc") ||
+ STRPREFIX(machine, "pc-0.") ||
+ STRPREFIX(machine, "pc-1.") ||
+ STRPREFIX(machine, "pc-i440") ||
+ STRPREFIX(machine, "rhel")));
}
@@ -6689,7 +6691,8 @@ qemuDomainIsS390CCW(const virDomainDef *def)
bool
qemuDomainMachineIsS390CCW(const char *machine)
{
- return STRPREFIX(machine, "s390-ccw");
+ return (machine &&
+ STRPREFIX(machine, "s390-ccw"));
}
@@ -6708,11 +6711,9 @@ qemuDomainMachineIsVirt(const char *machine,
arch != VIR_ARCH_AARCH64)
return false;
- if (STRNEQ(machine, "virt") &&
- !STRPREFIX(machine, "virt-"))
- return false;
-
- return true;
+ return (machine &&
+ (STREQ(machine, "virt") ||
+ STRPREFIX(machine, "virt-")));
}
@@ -6730,11 +6731,9 @@ qemuDomainMachineIsPSeries(const char *machine,
if (!ARCH_IS_PPC64(arch))
return false;
- if (STRNEQ(machine, "pseries") &&
- !STRPREFIX(machine, "pseries-"))
- return false;
-
- return true;
+ return (machine &&
+ (STREQ(machine, "pseries") ||
+ STRPREFIX(machine, "pseries-")));
}
diff --git a/tests/qemuargv2xmldata/qemuargv2xml-nomachine-aarch64.args b/tests/qemuargv2xmldata/qemuargv2xml-nomachine-aarch64.args
new file mode 100644
index 000000000..b17c0d0c2
--- /dev/null
+++ b/tests/qemuargv2xmldata/qemuargv2xml-nomachine-aarch64.args
@@ -0,0 +1,11 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-aarch64 \
+-name QEMUGuest1 \
+-m 512 \
+-hda /dev/HostVG/QEMUGuest1 \
+-cdrom /root/boot.iso
diff --git a/tests/qemuargv2xmldata/qemuargv2xml-nomachine-aarch64.xml b/tests/qemuargv2xmldata/qemuargv2xml-nomachine-aarch64.xml
new file mode 100644
index 000000000..eb8f9db80
--- /dev/null
+++ b/tests/qemuargv2xmldata/qemuargv2xml-nomachine-aarch64.xml
@@ -0,0 +1,39 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>524288</memory>
+ <currentMemory unit='KiB'>524288</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='aarch64' machine='virt'>hvm</type>
+ </os>
+ <features>
+ <gic version='2'/>
+ </features>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-aarch64</emulator>
+ <disk type='block' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+ </disk>
+ <disk type='file' device='cdrom'>
+ <driver name='qemu' type='raw'/>
+ <source file='/root/boot.iso'/>
+ <target dev='hdc' bus='ide'/>
+ <readonly/>
+ <address type='drive' controller='0' bus='1' target='0' unit='0'/>
+ </disk>
+ <controller type='ide' index='0'/>
+ <graphics type='sdl'/>
+ <video>
+ <model type='cirrus' vram='16384' heads='1' primary='yes'/>
+ </video>
+ <memballoon model='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuargv2xmldata/qemuargv2xml-nomachine-ppc64.args b/tests/qemuargv2xmldata/qemuargv2xml-nomachine-ppc64.args
new file mode 100644
index 000000000..ac618775e
--- /dev/null
+++ b/tests/qemuargv2xmldata/qemuargv2xml-nomachine-ppc64.args
@@ -0,0 +1,11 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-ppc64 \
+-name QEMUGuest1 \
+-m 512 \
+-hda /dev/HostVG/QEMUGuest1 \
+-cdrom /root/boot.iso
diff --git a/tests/qemuargv2xmldata/qemuargv2xml-nomachine-ppc64.xml b/tests/qemuargv2xmldata/qemuargv2xml-nomachine-ppc64.xml
new file mode 100644
index 000000000..1e987f645
--- /dev/null
+++ b/tests/qemuargv2xmldata/qemuargv2xml-nomachine-ppc64.xml
@@ -0,0 +1,47 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>524288</memory>
+ <currentMemory unit='KiB'>524288</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='ppc64' machine='pseries'>hvm</type>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-ppc64</emulator>
+ <disk type='block' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+ </disk>
+ <disk type='file' device='cdrom'>
+ <driver name='qemu' type='raw'/>
+ <source file='/root/boot.iso'/>
+ <target dev='hdc' bus='ide'/>
+ <readonly/>
+ <address type='drive' controller='0' bus='1' target='0' unit='0'/>
+ </disk>
+ <controller type='usb' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
+ </controller>
+ <controller type='pci' index='0' model='pci-root'>
+ <model name='spapr-pci-host-bridge'/>
+ <target index='0'/>
+ </controller>
+ <controller type='ide' index='0'/>
+ <input type='keyboard' bus='usb'/>
+ <input type='mouse' bus='usb'/>
+ <graphics type='sdl'/>
+ <video>
+ <model type='cirrus' vram='16384' heads='1' primary='yes'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
+ </video>
+ <memballoon model='none'/>
+ <panic model='pseries'/>
+ </devices>
+</domain>
diff --git a/tests/qemuargv2xmldata/qemuargv2xml-nomachine-x86_64.args b/tests/qemuargv2xmldata/qemuargv2xml-nomachine-x86_64.args
new file mode 100644
index 000000000..22bc4fb1c
--- /dev/null
+++ b/tests/qemuargv2xmldata/qemuargv2xml-nomachine-x86_64.args
@@ -0,0 +1,11 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-x86_64 \
+-name QEMUGuest1 \
+-m 512 \
+-hda /dev/HostVG/QEMUGuest1 \
+-cdrom /root/boot.iso
diff --git a/tests/qemuargv2xmldata/qemuargv2xml-nomachine-x86_64.xml b/tests/qemuargv2xmldata/qemuargv2xml-nomachine-x86_64.xml
new file mode 100644
index 000000000..71a36f083
--- /dev/null
+++ b/tests/qemuargv2xmldata/qemuargv2xml-nomachine-x86_64.xml
@@ -0,0 +1,48 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>524288</memory>
+ <currentMemory unit='KiB'>524288</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='x86_64' machine='pc-0.11'>hvm</type>
+ </os>
+ <features>
+ <acpi/>
+ </features>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-x86_64</emulator>
+ <disk type='block' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+ </disk>
+ <disk type='file' device='cdrom'>
+ <driver name='qemu' type='raw'/>
+ <source file='/root/boot.iso'/>
+ <target dev='hdc' bus='ide'/>
+ <readonly/>
+ <address type='drive' controller='0' bus='1' target='0' unit='0'/>
+ </disk>
+ <controller type='usb' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
+ </controller>
+ <controller type='pci' index='0' model='pci-root'/>
+ <controller type='ide' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
+ </controller>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <graphics type='sdl'/>
+ <video>
+ <model type='cirrus' vram='16384' heads='1' primary='yes'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
+ </video>
+ <memballoon model='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuargv2xmltest.c b/tests/qemuargv2xmltest.c
index 1adbcfef6..5d261afa6 100644
--- a/tests/qemuargv2xmltest.c
+++ b/tests/qemuargv2xmltest.c
@@ -288,6 +288,10 @@ mymain(void)
DO_TEST("machine-deakeywrap-off-argv");
DO_TEST("machine-keywrap-none-argv");
+ DO_TEST("nomachine-x86_64");
+ DO_TEST("nomachine-aarch64");
+ DO_TEST("nomachine-ppc64");
+
qemuTestDriverFree(&driver);
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
--
2.13.6
7 years, 2 months
[libvirt] [PATCH] spec: Install README.md
by Jiri Denemark
Installing dead README symlink only is pretty useless.
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
libvirt.spec.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libvirt.spec.in b/libvirt.spec.in
index e053f05f1c..0e72e167a3 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -1737,7 +1737,7 @@ exit 0
%files
%files docs
-%doc AUTHORS ChangeLog.gz NEWS README TODO
+%doc AUTHORS ChangeLog.gz NEWS README README.md TODO
%doc libvirt-docs/*
# API docs
--
2.14.2
7 years, 2 months
[libvirt] [libvit-jenkins-ci PATCH v2 00/16] Ansible all the things!
by Andrea Bolognani
Changes from [v1]:
* drop support for building projects;
* reduce redundancy by using mappings;
* add FreeBSD 10 support.
[v1] https://www.redhat.com/archives/libvir-list/2017-October/msg00035.html
Andrea Bolognani (16):
ansible: Initial support
ansible: Add libosinfo project
ansible: Add libvirt project
ansible: Add libvirt-cim project
ansible: Add libvirt-glib project
ansible: Add libvirt-go project
ansible: Add libvirt-go-xml project
ansible: Add libvirt-perl project
ansible: Add libvirt-python project
ansible: Add libvirt-sandbox project
ansible: Add libvirt-tck project
ansible: Add osinfo-db project
ansible: Add osinfo-db-tools project
ansible: Add virt-manager project
ansible: Add virt-viewer project
ansible: Install and configure Jenkins agent
ansible/.gitignore | 3 +
ansible/Makefile | 12 +
ansible/README.markdown | 60 ++
ansible/ansible.cfg | 9 +
ansible/bootstrap.yml | 15 +
ansible/group_vars/all/main.yml | 10 +
ansible/host_vars/libvirt-centos-6/main.yml | 10 +
ansible/host_vars/libvirt-centos-6/vault.yml | 10 +
ansible/host_vars/libvirt-centos-7/main.yml | 19 +
ansible/host_vars/libvirt-centos-7/vault.yml | 10 +
ansible/host_vars/libvirt-debian-8/main.yml | 17 +
ansible/host_vars/libvirt-debian-8/vault.yml | 10 +
ansible/host_vars/libvirt-debian-9/main.yml | 19 +
ansible/host_vars/libvirt-debian-9/vault.yml | 10 +
ansible/host_vars/libvirt-fedora-25/main.yml | 20 +
ansible/host_vars/libvirt-fedora-25/vault.yml | 10 +
ansible/host_vars/libvirt-fedora-26/main.yml | 20 +
ansible/host_vars/libvirt-fedora-26/vault.yml | 10 +
ansible/host_vars/libvirt-fedora-rawhide/main.yml | 20 +
ansible/host_vars/libvirt-fedora-rawhide/vault.yml | 10 +
ansible/host_vars/libvirt-freebsd-10/main.yml | 25 +
ansible/host_vars/libvirt-freebsd-10/vault.yml | 10 +
ansible/host_vars/libvirt-freebsd-11/main.yml | 25 +
ansible/host_vars/libvirt-freebsd-11/vault.yml | 10 +
ansible/host_vars/libvirt-ubuntu-12/main.yml | 7 +
ansible/host_vars/libvirt-ubuntu-12/vault.yml | 8 +
ansible/host_vars/libvirt-ubuntu-14/main.yml | 14 +
ansible/host_vars/libvirt-ubuntu-14/vault.yml | 8 +
ansible/host_vars/libvirt-ubuntu-16/main.yml | 18 +
ansible/host_vars/libvirt-ubuntu-16/vault.yml | 8 +
ansible/inventory | 9 +
ansible/site.yml | 27 +
ansible/tasks/base.yml | 108 ++++
ansible/tasks/bootstrap.yml | 22 +
ansible/tasks/compat.yml | 31 +
ansible/tasks/jenkins.yml | 59 ++
ansible/tasks/packages.yml | 66 ++
ansible/templates/jenkins.service.j2 | 14 +
ansible/vars/mappings.yml | 684 +++++++++++++++++++++
ansible/vars/projects/base.yml | 17 +
ansible/vars/projects/jenkins.yml | 3 +
ansible/vars/projects/libosinfo.yml | 15 +
ansible/vars/projects/libvirt-cim.yml | 8 +
ansible/vars/projects/libvirt-glib.yml | 8 +
ansible/vars/projects/libvirt-go-xml.yml | 3 +
ansible/vars/projects/libvirt-go.yml | 3 +
ansible/vars/projects/libvirt-perl.yml | 8 +
ansible/vars/projects/libvirt-python.yml | 8 +
ansible/vars/projects/libvirt-sandbox.yml | 14 +
ansible/vars/projects/libvirt-tck.yml | 21 +
ansible/vars/projects/libvirt.yml | 78 +++
ansible/vars/projects/osinfo-db-tools.yml | 8 +
ansible/vars/projects/osinfo-db.yml | 4 +
ansible/vars/projects/virt-manager.yml | 7 +
ansible/vars/projects/virt-viewer.yml | 10 +
55 files changed, 1672 insertions(+)
create mode 100644 ansible/.gitignore
create mode 100644 ansible/Makefile
create mode 100644 ansible/README.markdown
create mode 100644 ansible/ansible.cfg
create mode 100644 ansible/bootstrap.yml
create mode 100644 ansible/group_vars/all/main.yml
create mode 100644 ansible/host_vars/libvirt-centos-6/main.yml
create mode 100644 ansible/host_vars/libvirt-centos-6/vault.yml
create mode 100644 ansible/host_vars/libvirt-centos-7/main.yml
create mode 100644 ansible/host_vars/libvirt-centos-7/vault.yml
create mode 100644 ansible/host_vars/libvirt-debian-8/main.yml
create mode 100644 ansible/host_vars/libvirt-debian-8/vault.yml
create mode 100644 ansible/host_vars/libvirt-debian-9/main.yml
create mode 100644 ansible/host_vars/libvirt-debian-9/vault.yml
create mode 100644 ansible/host_vars/libvirt-fedora-25/main.yml
create mode 100644 ansible/host_vars/libvirt-fedora-25/vault.yml
create mode 100644 ansible/host_vars/libvirt-fedora-26/main.yml
create mode 100644 ansible/host_vars/libvirt-fedora-26/vault.yml
create mode 100644 ansible/host_vars/libvirt-fedora-rawhide/main.yml
create mode 100644 ansible/host_vars/libvirt-fedora-rawhide/vault.yml
create mode 100644 ansible/host_vars/libvirt-freebsd-10/main.yml
create mode 100644 ansible/host_vars/libvirt-freebsd-10/vault.yml
create mode 100644 ansible/host_vars/libvirt-freebsd-11/main.yml
create mode 100644 ansible/host_vars/libvirt-freebsd-11/vault.yml
create mode 100644 ansible/host_vars/libvirt-ubuntu-12/main.yml
create mode 100644 ansible/host_vars/libvirt-ubuntu-12/vault.yml
create mode 100644 ansible/host_vars/libvirt-ubuntu-14/main.yml
create mode 100644 ansible/host_vars/libvirt-ubuntu-14/vault.yml
create mode 100644 ansible/host_vars/libvirt-ubuntu-16/main.yml
create mode 100644 ansible/host_vars/libvirt-ubuntu-16/vault.yml
create mode 100644 ansible/inventory
create mode 100644 ansible/site.yml
create mode 100644 ansible/tasks/base.yml
create mode 100644 ansible/tasks/bootstrap.yml
create mode 100644 ansible/tasks/compat.yml
create mode 100644 ansible/tasks/jenkins.yml
create mode 100644 ansible/tasks/packages.yml
create mode 100644 ansible/templates/jenkins.service.j2
create mode 100644 ansible/vars/mappings.yml
create mode 100644 ansible/vars/projects/base.yml
create mode 100644 ansible/vars/projects/jenkins.yml
create mode 100644 ansible/vars/projects/libosinfo.yml
create mode 100644 ansible/vars/projects/libvirt-cim.yml
create mode 100644 ansible/vars/projects/libvirt-glib.yml
create mode 100644 ansible/vars/projects/libvirt-go-xml.yml
create mode 100644 ansible/vars/projects/libvirt-go.yml
create mode 100644 ansible/vars/projects/libvirt-perl.yml
create mode 100644 ansible/vars/projects/libvirt-python.yml
create mode 100644 ansible/vars/projects/libvirt-sandbox.yml
create mode 100644 ansible/vars/projects/libvirt-tck.yml
create mode 100644 ansible/vars/projects/libvirt.yml
create mode 100644 ansible/vars/projects/osinfo-db-tools.yml
create mode 100644 ansible/vars/projects/osinfo-db.yml
create mode 100644 ansible/vars/projects/virt-manager.yml
create mode 100644 ansible/vars/projects/virt-viewer.yml
--
2.13.6
7 years, 2 months
[libvirt] [PATCH] qemu: Floppy disks not supported on pSeries machines
by Kothapally Madhu Pavan
Signed-off-by: Kothapally Madhu Pavan <kmp(a)linux.vnet.ibm.com>
---
src/qemu/qemu_parse_command.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/qemu/qemu_parse_command.c b/src/qemu/qemu_parse_command.c
index 7c409b0..d5745ce 100644
--- a/src/qemu/qemu_parse_command.c
+++ b/src/qemu/qemu_parse_command.c
@@ -760,6 +760,11 @@ qemuParseCommandLineDisk(virDomainXMLOptionPtr xmlopt,
} else if (STREQ(values[i], "floppy")) {
def->bus = VIR_DOMAIN_DISK_BUS_FDC;
def->device = VIR_DOMAIN_DISK_DEVICE_FLOPPY;
+ if (qemuDomainIsPSeries(dom)) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("pseries systems do not support floppy devices '%s'"), val);
+ goto error;
+ }
} else if (STREQ(values[i], "virtio")) {
def->bus = VIR_DOMAIN_DISK_BUS_VIRTIO;
} else if (STREQ(values[i], "xen")) {
--
1.8.3.1
7 years, 2 months
[libvirt] [RFC PATCH 0/4] Deadlock fix and some minor fixes
by Marc Hartmayer
The first patch is a preparatory patch for the deadlock fix (patch
2). The cleanup path for 'virExecCommon' may now be superflous.
Patches 3-4 are only minor fixes.
Important: there may still be a deadlock for LXC (see the TODO in
patch 2)
Marc Hartmayer (4):
util: Add virCommandGetGID and virCommandGetUID
util: Fix deadlock across fork()
lxc: Fixed a typo
lxc: Fixed indentation
src/libvirt_private.syms | 2 ++
src/lxc/lxc_container.c | 20 +++++++++++++++-----
src/util/vircommand.c | 39 ++++++++++++++++++++++++++++-----------
src/util/vircommand.h | 6 +++++-
tests/commandtest.c | 15 ++++++++++-----
5 files changed, 60 insertions(+), 22 deletions(-)
--
2.5.5
7 years, 2 months
[libvirt] [PATCH] qemu: Remove redundant code in qemuParseCommandLineDisk
by Kothapally Madhu Pavan
Signed-off-by: Kothapally Madhu Pavan <kmp(a)linux.vnet.ibm.com>
---
src/qemu/qemu_parse_command.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/src/qemu/qemu_parse_command.c b/src/qemu/qemu_parse_command.c
index 37e1149..7c409b0 100644
--- a/src/qemu/qemu_parse_command.c
+++ b/src/qemu/qemu_parse_command.c
@@ -945,9 +945,7 @@ qemuParseCommandLineDisk(virDomainXMLOptionPtr xmlopt,
if (virDomainDiskDefAssignAddress(xmlopt, def, dom) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("invalid device name '%s'"), def->dst);
- virDomainDiskDefFree(def);
- def = NULL;
- goto cleanup;
+ goto error;
}
cleanup:
--
1.8.3.1
7 years, 2 months
[libvirt] gnulib tests in libvirt broken by newer glibc 2.26
by Christian Ehrhardt
Hi,
there seems to be an incompatibility to the last glibc due to [1].
Eventually this breaks gnulib unittests (and maybe more).
Debugging went from an assert, to bidngin different symbols, to changed
function names to different header resolution.
Because it expects it to behave "posixly" but arguments are changed
differently.
FAIL: test-getopt-posix
=======================
../../../../gnulib/tests/test-getopt.h:754: assertion 'strcmp (argv[1],
"donald") == 0' failed
# get and build latest libvirt to get the local gnulib
$ wget http://libvirt.org/sources/libvirt-3.7.0.tar.xz
$ tar xf libvirt-3.7.0.tar.xz
$ cd libvirt
$ apt build-dep libvirt
$ ./autogen.sh
$ make -j4
You can run the following simplified test derived from the unit test (it is
much shorter, so easier to debug e.g. in -E).
$ cat << EOF >> test1.c
#include <config.h>
#include <unistd.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
int main (void)
{
return 0;
}
EOF
$ gcc -I ./gnulib/lib -I . test1.c -H
You can see in -H output already the difference in the paths of the headers
that it uses:
Glibc <2.26
. ./config.h
.. ./config-post.h
. /usr/include/unistd.h
[...]
.. /usr/include/getopt.h
Glibc >=2.26
. ./config.h
.. ./config-post.h
. ./gnulib/lib/unistd.h
[...]
... /usr/include/x86_64-linux-gnu/bits/getopt_posix.h
.... /usr/include/x86_64-linux-gnu/bits/getopt_core.
If you build with -E you'll also see that it now uses getopt from glibc
instead of the prefixed rpl_getopt from gnulib.
It behaves as if it would not find gnulib and instead fall back to glibc.
But it finds gnulib, instead due to glibc's changes its implementation is
fetched before and due to that pulling in glibc's behavior while the unit
test is verifying against the one it expects from gnulib.
Sorry, but I don't see the right fix here yet - I could easily silence the
test but that is no fix. Especially if there might be implications due to
handling the args (slightly) differently.
I really wanted to come up with the same test against gnulib alone, but I
was lost in the build system for too long and could not get the example to
fail without libvirt (OTOH I'm sure it would).
Therefore I'm reaching out to you for your help and experience on the build
system what could be done.
[1]: https://sourceware.org/ml/libc-alpha/2017-04/msg00115.html
--
Christian Ehrhardt
Software Engineer, Ubuntu Server
Canonical Ltd
7 years, 2 months
[libvirt] [PATCH v2] qemu: argv: parse qemu commandline memory arguments
by Kothapally Madhu Pavan
Existing qemuParseCommandLineMem() will parse "-m 4G" format string.
This patch allows it to parse "-m size=8126464k,slots=32,maxmem=33554432k"
format along with existing format. And adds a testcase to validate the changes.
Signed-off-by: Kothapally Madhu Pavan <kmp(a)linux.vnet.ibm.com>
---
src/qemu/qemu_parse_command.c | 89 +++++++++++++++++++---
.../qemuargv2xml-mem-scale-maxmemory.args | 22 ++++++
.../qemuargv2xml-mem-scale-maxmemory.xml | 38 +++++++++
tests/qemuargv2xmltest.c | 1 +
4 files changed, 138 insertions(+), 12 deletions(-)
create mode 100644 tests/qemuargv2xmldata/qemuargv2xml-mem-scale-maxmemory.args
create mode 100644 tests/qemuargv2xmldata/qemuargv2xml-mem-scale-maxmemory.xml
diff --git a/src/qemu/qemu_parse_command.c b/src/qemu/qemu_parse_command.c
index 37e1149..f8b6f8b 100644
--- a/src/qemu/qemu_parse_command.c
+++ b/src/qemu/qemu_parse_command.c
@@ -1629,26 +1629,91 @@ static int
qemuParseCommandLineMem(virDomainDefPtr dom,
const char *val)
{
- unsigned long long mem;
+ unsigned long long mem = 0;
+ unsigned long long size = 0;
+ unsigned long long maxmem = 0;
+ unsigned int slots = 0;
char *end;
+ size_t i;
+ int nkws;
+ char **kws;
+ char **vals;
+ int n;
+ int ret = -1;
- if (virStrToLong_ull(val, &end, 10, &mem) < 0) {
+ if (qemuParseKeywords(val, &kws, &vals, &nkws, 1) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
- _("cannot parse memory level '%s'"), val);
- return -1;
+ _("cannot parse memory '%s'"), val);
+ goto cleanup;
}
- if (virScaleInteger(&mem, end, 1024*1024, ULLONG_MAX) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("cannot scale memory: %s"),
- virGetLastErrorMessage());
- return -1;
+ for (i = 0; i < nkws; i++) {
+ if (vals[i] == NULL) {
+ if (i > 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("cannot parse memory '%s'"), val);
+ goto cleanup;
+ }
+ if (virStrToLong_ull(kws[i], &end, 10, &mem) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("cannot parse memory level '%s'"), kws[i]);
+ goto cleanup;
+ }
+ if (virScaleInteger(&mem, end, 1024*1024, ULLONG_MAX) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("cannot scale memory: %s"),
+ virGetLastErrorMessage());
+ goto cleanup;
+ }
+
+ size = mem;
+
+ } else {
+ if (STREQ(kws[i], "size") || STREQ(kws[i], "maxmem")) {
+ if (virStrToLong_ull(vals[i], &end, 10, &mem) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("cannot parse memory level '%s'"), vals[i]);
+ goto cleanup;
+ }
+ if (virScaleInteger(&mem, end, 1024*1024, ULLONG_MAX) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("cannot scale memory: %s"),
+ virGetLastErrorMessage());
+ goto cleanup;
+ }
+
+ STREQ(kws[i], "size") ? (size = mem) : (maxmem = mem);
+
+ }
+ if (STREQ(kws[i], "slots")) {
+ if (virStrToLong_i(vals[i], &end, 10, &n) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("cannot parse slots value '%s'"), vals[i]);
+ goto cleanup;
+ }
+
+ slots = n;
+
+ }
+ }
}
- virDomainDefSetMemoryTotal(dom, mem / 1024);
- dom->mem.cur_balloon = mem / 1024;
+ virDomainDefSetMemoryTotal(dom, size / 1024);
+ dom->mem.cur_balloon = size / 1024;
+ dom->mem.memory_slots = slots;
+ dom->mem.max_memory = maxmem;
- return 0;
+ ret = 0;
+
+ cleanup:
+ for (i = 0; i < nkws; i++) {
+ VIR_FREE(kws[i]);
+ VIR_FREE(vals[i]);
+ }
+ VIR_FREE(kws);
+ VIR_FREE(vals);
+
+ return ret;
}
diff --git a/tests/qemuargv2xmldata/qemuargv2xml-mem-scale-maxmemory.args b/tests/qemuargv2xmldata/qemuargv2xml-mem-scale-maxmemory.args
new file mode 100644
index 0000000..7bce841
--- /dev/null
+++ b/tests/qemuargv2xmldata/qemuargv2xml-mem-scale-maxmemory.args
@@ -0,0 +1,22 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-i686 \
+-name QEMUGuest1 \
+-S \
+-M pc \
+-m 8G,slots=16,maxmem=16G \
+-smp 1,maxcpus=2,sockets=2,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-nographic \
+-monitor unix:/tmp/test-monitor,server,nowait \
+-no-acpi \
+-boot c \
+-usb \
+-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=ide,bus=0,unit=0 \
+-net none \
+-serial none \
+-parallel none
diff --git a/tests/qemuargv2xmldata/qemuargv2xml-mem-scale-maxmemory.xml b/tests/qemuargv2xmldata/qemuargv2xml-mem-scale-maxmemory.xml
new file mode 100644
index 0000000..328c4ed
--- /dev/null
+++ b/tests/qemuargv2xmldata/qemuargv2xml-mem-scale-maxmemory.xml
@@ -0,0 +1,38 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <maxMemory slots='16' unit='KiB'>17179869184</maxMemory>
+ <memory unit='KiB'>8388608</memory>
+ <currentMemory unit='KiB'>8388608</currentMemory>
+ <vcpu placement='static' current='1'>2</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <cpu>
+ <topology sockets='2' cores='1' threads='1'/>
+ </cpu>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-i686</emulator>
+ <disk type='block' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+ </disk>
+ <controller type='usb' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
+ </controller>
+ <controller type='pci' index='0' model='pci-root'/>
+ <controller type='ide' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
+ </controller>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <memballoon model='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuargv2xmltest.c b/tests/qemuargv2xmltest.c
index 1adbcfe..e35726e 100644
--- a/tests/qemuargv2xmltest.c
+++ b/tests/qemuargv2xmltest.c
@@ -265,6 +265,7 @@ mymain(void)
DO_TEST("hostdev-pci-address");
DO_TEST("mem-scale");
+ DO_TEST("mem-scale-maxmemory");
DO_TEST("smp");
DO_TEST("hyperv");
--
1.8.3.1
7 years, 2 months