[libvirt] [PATCH] Fix guest boot failure when vcpu placement="auto" on memoryless numa node
by Nitesh Konkar
When the vcpu placement is auto and we have memoryless numa nodes on the host,
numad returns a list numa nodes with and without memory. When we try to write it
to /sys/fs/cgroup/*/cpuset.mems it errors out as invlaid argument.
Signed-off-by: Nitesh Konkar <nitkon12(a)linux.vnet.ibm.com>
---
numactl --hardware
available: 4 nodes (0-1,16-17)
node 0 cpus: 0 8 16 24 32
node 0 size: 32500 MB
node 0 free: 25584 MB
node 1 cpus: 40 48 56 64 72
node 1 size: 0 MB----------------------------------------------#
node 1 free: 0 MB
node 16 cpus: 80 88 96 104 112
node 16 size: 32613 MB
node 16 free: 30991 MB
node 17 cpus: 120 128 136 144 152
node 17 size: 0 MB--------------------------------------------#
node 17 free: 0 MB
node distances:
node 0 1 16 17
0: 10 20 40 40
1: 20 10 40 40
16: 40 40 10 20
17: 40 40 20 10
virsh start virt-tests-vm1
error: Failed to start domain virt-tests-vm1
error: Invalid value '0-1,16-17' for 'cpuset.mems': Invalid argument--------------NOK
src/qemu/qemu_cgroup.c | 4 +++-
src/qemu/qemu_process.c | 5 ++++-
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
index 36762d4..fd8deb1 100644
--- a/src/qemu/qemu_cgroup.c
+++ b/src/qemu/qemu_cgroup.c
@@ -723,10 +723,12 @@ qemuSetupCpusetMems(virDomainObjPtr vm)
{
virCgroupPtr cgroup_temp = NULL;
qemuDomainObjPrivatePtr priv = vm->privateData;
+ virBitmapPtr nodeSet = NULL;
virDomainNumatuneMemMode mode;
char *mem_mask = NULL;
int ret = -1;
+ nodeSet = virNumaGetHostMemoryNodeset();
if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPUSET))
return 0;
@@ -735,7 +737,7 @@ qemuSetupCpusetMems(virDomainObjPtr vm)
return 0;
if (virDomainNumatuneMaybeFormatNodeset(vm->def->numa,
- priv->autoNodeset,
+ nodeSet,
&mem_mask, -1) < 0)
goto cleanup;
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index fa9990e..074a0cd 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -2374,6 +2374,7 @@ qemuProcessSetupPid(virDomainObjPtr vm,
virDomainNumatuneMemMode mem_mode;
virCgroupPtr cgroup = NULL;
virBitmapPtr use_cpumask;
+ virBitmapPtr nodeSet = NULL;
char *mem_mask = NULL;
int ret = -1;
@@ -2397,13 +2398,15 @@ qemuProcessSetupPid(virDomainObjPtr vm,
* neither period nor quota settings. And if CPUSET controller is
* not initialized either, then there's nothing to do anyway.
*/
+ nodeSet = virNumaGetHostMemoryNodeset();
+
if (virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPU) ||
virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPUSET)) {
if (virDomainNumatuneGetMode(vm->def->numa, -1, &mem_mode) == 0 &&
mem_mode == VIR_DOMAIN_NUMATUNE_MEM_STRICT &&
virDomainNumatuneMaybeFormatNodeset(vm->def->numa,
- priv->autoNodeset,
+ nodeSet,
&mem_mask, -1) < 0)
goto cleanup;
--
1.8.3.1
7 years, 5 months
[libvirt] [PATCH go-xml] Add support for domain clock and test code
by zhenwei.pi
Signed-off-by: zhenwei.pi <zhenwei.pi(a)youruncloud.com>
---
domain.go | 5 +++++
domain_test.go | 4 ++++
2 files changed, 9 insertions(+)
diff --git a/domain.go b/domain.go
index b9b0f77..8bbf82b 100644
--- a/domain.go
+++ b/domain.go
@@ -532,6 +532,10 @@ type DomainCPU struct {
Features []DomainCPUFeature `xml:"feature"`
}
+type DomainClock struct {
+ Offset string `xml:"offset,attr,omitempty"`
+}
+
type DomainFeature struct {
}
@@ -607,6 +611,7 @@ type Domain struct {
OS *DomainOS `xml:"os"`
Features *DomainFeatureList `xml:"features"`
CPU *DomainCPU `xml:"cpu"`
+ Clock *DomainClock `xml:"clock,omitempty"`
OnPoweroff string `xml:"on_poweroff,omitempty"`
OnReboot string `xml:"on_reboot,omitempty"`
OnCrash string `xml:"on_crash,omitempty"`
diff --git a/domain_test.go b/domain_test.go
index 47e5e26..a263e72 100644
--- a/domain_test.go
+++ b/domain_test.go
@@ -491,6 +491,9 @@ var domainTestData = []struct {
},
},
},
+ Clock: &DomainClock{
+ Offset: "utc",
+ },
},
Expected: []string{
`<domain type="kvm">`,
@@ -524,6 +527,7 @@ var domainTestData = []struct {
` <initarg>--unit</initarg>`,
` <initarg>emergency.service</initarg>`,
` </os>`,
+ ` <clock offset="utc"></clock>`,
`</domain>`,
},
},
--
2.7.4
7 years, 5 months
[libvirt] [PATCH v2] test: adding tests to virStrToDouble() inside virstringtest.
by Julio Faracco
There are no occurrences of tests related to Strings and Double numbers
inside virstringtest.c. This commit introduces some tests to validate the
conversion. The test does not include locale changes yet.
Signed-off-by: Julio Faracco <jcfaracco(a)gmail.com>
---
tests/virstringtest.c | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 80 insertions(+)
diff --git a/tests/virstringtest.c b/tests/virstringtest.c
index 97c6e76..cc95d3c 100644
--- a/tests/virstringtest.c
+++ b/tests/virstringtest.c
@@ -652,6 +652,48 @@ testStringToLong(const void *opaque)
}
+struct stringToDoubleData {
+ const char *str;
+ const char *end_ptr;
+ double res;
+};
+
+/* This test checks if double strings are successfully converted to double
+ * number considering the byproduct string too. */
+static int
+testStringToDouble(const void *opaque)
+{
+ const struct stringToDoubleData *data = opaque;
+ int ret = -1;
+ char *end_ptr = NULL;
+ double res = 0;
+
+ /* end_ptr returns or a substring or an empty string.
+ * It never returns a NULL pointer. */
+ if ((ret = virStrToDouble(data->str,
+ data->end_ptr ? &end_ptr : NULL,
+ &res)) < 0) {
+ fprintf(stderr, "Convert error of '%s', expected '%lf'\n",
+ data->str, data->res);
+ return ret;
+ }
+
+ if (res != data->res) {
+ fprintf(stderr, "Returned '%lf', expected '%lf'\n",
+ res, data->res);
+ return -1;
+ }
+
+ /* Comparing substrings. */
+ if (STRNEQ_NULLABLE(end_ptr, data->end_ptr)) {
+ fprintf(stderr, "Expected substring '%s', but got '%s'\n",
+ end_ptr, data->end_ptr);
+ return -1;
+ }
+
+ return ret;
+}
+
/* The point of this test is to check whether all members of the array are
* freed. The test has to be checked using valgrind. */
static int
@@ -965,6 +1007,44 @@ mymain(void)
TEST_STRTOL("-18446744073709551616", NULL, 0, -1, 0U, -1,
0LL, -1, 0ULL, -1);
+#define TEST_STRTOD(str, end_ptr, res) \
+ do { \
+ struct stringToDoubleData data = { \
+ str, end_ptr, res, \
+ }; \
+ if (virTestRun("virStringToDouble '" str "'", \
+ testStringToDouble, &data) < 0) \
+ ret = -1; \
+ } while (0)
+
+ /* Simple numbers. */
+ TEST_STRTOD("0.0", NULL, 0);
+ TEST_STRTOD("1.0", NULL, 1);
+ TEST_STRTOD("3.14159", NULL, 3.14159);
+ TEST_STRTOD("0.57721", NULL, 0.57721);
+
+ /* Testing ending string. */
+ TEST_STRTOD("2.718", "", 2.718);
+ TEST_STRTOD("2.718 281 828 459", " 281 828 459", 2.718);
+ TEST_STRTOD("2.718,281,828,459", ",281,828,459", 2.718);
+
+ /* Scientific numbers. */
+ TEST_STRTOD("3.14159e+000", NULL, 3.14159);
+ TEST_STRTOD("2.00600e+003", NULL, 2006);
+ TEST_STRTOD("1.00000e-010", NULL, 1e-010);
+
+ /* Negative numbers. */
+ TEST_STRTOD("-1.6180339887", NULL, -1.6180339887);
+ TEST_STRTOD("-0.00031e-010", NULL, -0.00031e-010);
+
+ /* Long numbers. */
+ TEST_STRTOD("57089907708238388904078437636832797971793838081897.0",
+ NULL,
+ 57089907708238388904078437636832797971793838081897.0);
+ TEST_STRTOD("3.141592653589793238462643383279502884197169399375105",
+ NULL,
+ 3.141592653589793238462643383279502884197169399375105);
+
/* test virStringListFreeCount */
if (virTestRun("virStringListFreeCount", testVirStringListFreeCount,
NULL) < 0)
--
2.7.4
7 years, 5 months
[libvirt] [PATCH v2] test: adding tests to virStrToDouble() inside virstringtest.
by Julio Faracco
There are no occurrences of tests related to Strings and Double numbers
inside virstringtest.c. This commit introduces some tests to validate the
conversion. The test does not include locale changes yet.
Signed-off-by: Julio Faracco <jcfaracco(a)gmail.com>
---
tests/virstringtest.c | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 80 insertions(+)
diff --git a/tests/virstringtest.c b/tests/virstringtest.c
index 97c6e76..cc95d3c 100644
--- a/tests/virstringtest.c
+++ b/tests/virstringtest.c
@@ -652,6 +652,48 @@ testStringToLong(const void *opaque)
}
+struct stringToDoubleData {
+ const char *str;
+ const char *end_ptr;
+ double res;
+};
+
+/* This test checks if double strings are successfully converted to double
+ * number considering the byproduct string too. */
+static int
+testStringToDouble(const void *opaque)
+{
+ const struct stringToDoubleData *data = opaque;
+ int ret = -1;
+ char *end_ptr = NULL;
+ double res = 0;
+
+ /* end_ptr returns or a substring or an empty string.
+ * It never returns a NULL pointer. */
+ if ((ret = virStrToDouble(data->str,
+ data->end_ptr ? &end_ptr : NULL,
+ &res)) < 0) {
+ fprintf(stderr, "Convert error of '%s', expected '%lf'\n",
+ data->str, data->res);
+ return ret;
+ }
+
+ if (res != data->res) {
+ fprintf(stderr, "Returned '%lf', expected '%lf'\n",
+ res, data->res);
+ return -1;
+ }
+
+ /* Comparing substrings. */
+ if (STRNEQ_NULLABLE(end_ptr, data->end_ptr)) {
+ fprintf(stderr, "Expected substring '%s', but got '%s'\n",
+ end_ptr, data->end_ptr);
+ return -1;
+ }
+
+ return ret;
+}
+
/* The point of this test is to check whether all members of the array are
* freed. The test has to be checked using valgrind. */
static int
@@ -965,6 +1007,44 @@ mymain(void)
TEST_STRTOL("-18446744073709551616", NULL, 0, -1, 0U, -1,
0LL, -1, 0ULL, -1);
+#define TEST_STRTOD(str, end_ptr, res) \
+ do { \
+ struct stringToDoubleData data = { \
+ str, end_ptr, res, \
+ }; \
+ if (virTestRun("virStringToDouble '" str "'", \
+ testStringToDouble, &data) < 0) \
+ ret = -1; \
+ } while (0)
+
+ /* Simple numbers. */
+ TEST_STRTOD("0.0", NULL, 0);
+ TEST_STRTOD("1.0", NULL, 1);
+ TEST_STRTOD("3.14159", NULL, 3.14159);
+ TEST_STRTOD("0.57721", NULL, 0.57721);
+
+ /* Testing ending string. */
+ TEST_STRTOD("2.718", "", 2.718);
+ TEST_STRTOD("2.718 281 828 459", " 281 828 459", 2.718);
+ TEST_STRTOD("2.718,281,828,459", ",281,828,459", 2.718);
+
+ /* Scientific numbers. */
+ TEST_STRTOD("3.14159e+000", NULL, 3.14159);
+ TEST_STRTOD("2.00600e+003", NULL, 2006);
+ TEST_STRTOD("1.00000e-010", NULL, 1e-010);
+
+ /* Negative numbers. */
+ TEST_STRTOD("-1.6180339887", NULL, -1.6180339887);
+ TEST_STRTOD("-0.00031e-010", NULL, -0.00031e-010);
+
+ /* Long numbers. */
+ TEST_STRTOD("57089907708238388904078437636832797971793838081897.0",
+ NULL,
+ 57089907708238388904078437636832797971793838081897.0);
+ TEST_STRTOD("3.141592653589793238462643383279502884197169399375105",
+ NULL,
+ 3.141592653589793238462643383279502884197169399375105);
+
/* test virStringListFreeCount */
if (virTestRun("virStringListFreeCount", testVirStringListFreeCount,
NULL) < 0)
--
2.7.4
7 years, 5 months
[libvirt] [PATCH] test: adding tests to virStrToDouble() inside virstringtest.
by Julio Faracco
There are no occurrences of tests related to Strings and Double numbers
inside virstringtest.c. This commit introduces some tests to validate the
conversion. The test does not include locale changes yet.
Signed-off-by: Julio Faracco <jcfaracco(a)gmail.com>
---
tests/virstringtest.c | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 84 insertions(+)
diff --git a/tests/virstringtest.c b/tests/virstringtest.c
index 97c6e76..32ce79c 100644
--- a/tests/virstringtest.c
+++ b/tests/virstringtest.c
@@ -652,6 +652,52 @@ testStringToLong(const void *opaque)
}
+struct stringToDoubleData {
+ const char *str;
+ const char *end_ptr;
+ double res;
+};
+
+/* This test checks if double strings are successfully converted to double
+ * number considering the byproduct string too. */
+static int
+testStringToDouble(const void *opaque)
+{
+ const struct stringToDoubleData *data = opaque;
+ int ret = -1;
+ char *end_ptr = NULL;
+ double res = 0;
+
+ if (data->end_ptr) {
+ ret = virStrToDouble(data->str, &end_ptr, &res);
+ } else {
+ /* end_ptr returns or a substring or an empty string.
+ * It never returns a NULL pointer. */
+ ret = virStrToDouble(data->str, NULL, &res);
+ }
+
+ if (ret < 0) {
+ fprintf(stderr, "Convert error of '%s', expected '%f'\n",
+ data->str, data->res);
+ return ret;
+ }
+
+ if (res != data->res) {
+ fprintf(stderr, "Returned '%f', expected '%f'\n",
+ res, data->res);
+ return -1;
+ }
+
+ /* Comparing substrings. */
+ if (STRNEQ_NULLABLE(end_ptr, data->end_ptr)) {
+ fprintf(stderr, "Expected substring '%s', but got '%s'\n",
+ end_ptr, data->end_ptr);
+ return -1;
+ }
+
+ return ret;
+}
+
/* The point of this test is to check whether all members of the array are
* freed. The test has to be checked using valgrind. */
static int
@@ -965,6 +1011,44 @@ mymain(void)
TEST_STRTOL("-18446744073709551616", NULL, 0, -1, 0U, -1,
0LL, -1, 0ULL, -1);
+#define TEST_STRTOD(str, end_ptr, res) \
+ do { \
+ struct stringToDoubleData data = { \
+ str, end_ptr, res, \
+ }; \
+ if (virTestRun("virStringToDouble '" str "'", \
+ testStringToDouble, &data) < 0) \
+ ret = -1; \
+ } while(0)
+
+ /* Simple numbers. */
+ TEST_STRTOD("0.0", NULL, 0);
+ TEST_STRTOD("1.0", NULL, 1);
+ TEST_STRTOD("3.14159", NULL, 3.14159);
+ TEST_STRTOD("0.57721", NULL, 0.57721);
+
+ /* Testing ending string. */
+ TEST_STRTOD("2.718", "", 2.718);
+ TEST_STRTOD("2.718 281 828 459", " 281 828 459", 2.718);
+ TEST_STRTOD("2.718,281,828,459", ",281,828,459", 2.718);
+
+ /* Scientific numbers. */
+ TEST_STRTOD("3.14159e+000", NULL, 3.14159);
+ TEST_STRTOD("2.00600e+003", NULL, 2006);
+ TEST_STRTOD("1.00000e-010", NULL, 1e-010);
+
+ /* Negative numbers. */
+ TEST_STRTOD("-1.6180339887", NULL, -1.6180339887);
+ TEST_STRTOD("-0.00031e-010", NULL, -0.00031e-010);
+
+ /* Long numbers. */
+ TEST_STRTOD("57089907708238388904078437636832797971793838081897.0",
+ NULL,
+ 57089907708238388904078437636832797971793838081897.0);
+ TEST_STRTOD("3.141592653589793238462643383279502884197169399375105",
+ NULL,
+ 3.141592653589793238462643383279502884197169399375105);
+
/* test virStringListFreeCount */
if (virTestRun("virStringListFreeCount", testVirStringListFreeCount,
NULL) < 0)
--
2.7.4
7 years, 5 months
[libvirt] [PATCH go-xml] Add support for domain clock
by zhenwei.pi
Signed-off-by: zhenwei.pi <zhenwei.pi(a)youruncloud.com>
---
domain.go | 5 +++++
domain_test.go | 4 ++++
2 files changed, 9 insertions(+)
diff --git a/domain.go b/domain.go
index b9b0f77..8bbf82b 100644
--- a/domain.go
+++ b/domain.go
@@ -532,6 +532,10 @@ type DomainCPU struct {
Features []DomainCPUFeature `xml:"feature"`
}
+type DomainClock struct {
+ Offset string `xml:"offset,attr,omitempty"`
+}
+
type DomainFeature struct {
}
@@ -607,6 +611,7 @@ type Domain struct {
OS *DomainOS `xml:"os"`
Features *DomainFeatureList `xml:"features"`
CPU *DomainCPU `xml:"cpu"`
+ Clock *DomainClock `xml:"clock,omitempty"`
OnPoweroff string `xml:"on_poweroff,omitempty"`
OnReboot string `xml:"on_reboot,omitempty"`
OnCrash string `xml:"on_crash,omitempty"`
diff --git a/domain_test.go b/domain_test.go
index 47e5e26..a263e72 100644
--- a/domain_test.go
+++ b/domain_test.go
@@ -491,6 +491,9 @@ var domainTestData = []struct {
},
},
},
+ Clock: &DomainClock{
+ Offset: "utc",
+ },
},
Expected: []string{
`<domain type="kvm">`,
@@ -524,6 +527,7 @@ var domainTestData = []struct {
` <initarg>--unit</initarg>`,
` <initarg>emergency.service</initarg>`,
` </os>`,
+ ` <clock offset="utc"></clock>`,
`</domain>`,
},
},
--
2.7.4
7 years, 5 months
[libvirt] [PATCH] qemu: shared disks with cache=directsync should be safe for migration
by Peng Hao
From: Hao Peng <peng.hao2(a)zte.com.cn>
At present shared disks can be migrated with either readonly or cache=none. But
cache=directsync should be safe for migration, because both cache=directsync and cache=none
don't use the host page cache, and cache=direct write through qemu block layer cache.
Signed-off-by: Peng Hao <peng.hao2(a)zte.com.cn>
Reviewed-by: Wang Yechao <wang.yechao255(a)zte.com.cn>
---
src/qemu/qemu_migration.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index c23fffe..9d509dd 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -1160,11 +1160,12 @@ qemuMigrationIsSafe(virDomainDefPtr def,
const char *src = virDomainDiskGetSource(disk);
/* Our code elsewhere guarantees shared disks are either readonly (in
- * which case cache mode doesn't matter) or used with cache=none */
+ * which case cache mode doesn't matter) or used with cache=none or used with cache=directsync */
if (virStorageSourceIsEmpty(disk->src) ||
disk->src->readonly ||
disk->src->shared ||
- disk->cachemode == VIR_DOMAIN_DISK_CACHE_DISABLE)
+ disk->cachemode == VIR_DOMAIN_DISK_CACHE_DISABLE ||
+ disk->cachemode == VIR_DOMAIN_DISK_CACHE_DIRECTSYNC)
continue;
/* disks which are migrated by qemu are safe too */
@@ -1188,7 +1189,7 @@ qemuMigrationIsSafe(virDomainDefPtr def,
virReportError(VIR_ERR_MIGRATE_UNSAFE, "%s",
_("Migration may lead to data corruption if disks"
- " use cache != none"));
+ " use cache != none or cache != directsync"));
return false;
}
--
1.8.3.1
7 years, 5 months
[libvirt] [PATCH go-xml] Add support for QEMU
by Thomas Hipp
Add support for QEMU, and add test code.
Signed-off-by: Thomas Hipp <thipp(a)suse.de>
---
domain.go | 50 +++++++++++++++++++++++++++++++++-----------------
domain_test.go | 20 ++++++++++++++++++++
2 files changed, 53 insertions(+), 17 deletions(-)
diff --git a/domain.go b/domain.go
index b9b0f77..15fdb3a 100644
--- a/domain.go
+++ b/domain.go
@@ -590,27 +590,43 @@ type DomainFeatureList struct {
SMM *DomainFeatureState `xml:"smm"`
}
+type DomainQEMUCommandlineArg struct {
+ Value string `xml:"value,attr"`
+}
+
+type DomainQEMUCommandlineEnv struct {
+ Name string `xml:"name,attr"`
+ Value string `xml:"value,attr,omitempty"`
+}
+
+type DomainQEMUCommandline struct {
+ Arg DomainQEMUCommandlineArg `xml:"qemu arg"`
+ Env DomainQEMUCommandlineEnv `xml:"qemu env"`
+}
+
// NB, try to keep the order of fields in this struct
// matching the order of XML elements that libvirt
// will generate when dumping XML.
type Domain struct {
- XMLName xml.Name `xml:"domain"`
- Type string `xml:"type,attr,omitempty"`
- Name string `xml:"name"`
- UUID string `xml:"uuid,omitempty"`
- Memory *DomainMemory `xml:"memory"`
- CurrentMemory *DomainMemory `xml:"currentMemory"`
- MaximumMemory *DomainMaxMemory `xml:"maxMemory"`
- VCPU *DomainVCPU `xml:"vcpu"`
- Resource *DomainResource `xml:"resource"`
- SysInfo *DomainSysInfo `xml:"sysinfo"`
- OS *DomainOS `xml:"os"`
- Features *DomainFeatureList `xml:"features"`
- CPU *DomainCPU `xml:"cpu"`
- OnPoweroff string `xml:"on_poweroff,omitempty"`
- OnReboot string `xml:"on_reboot,omitempty"`
- OnCrash string `xml:"on_crash,omitempty"`
- Devices *DomainDeviceList `xml:"devices"`
+ XMLName xml.Name `xml:"domain"`
+ XMLNS_QEMU string `xml:"xmlns qemu,attr,omitempty"`
+ Type string `xml:"type,attr,omitempty"`
+ Name string `xml:"name"`
+ UUID string `xml:"uuid,omitempty"`
+ Memory *DomainMemory `xml:"memory"`
+ CurrentMemory *DomainMemory `xml:"currentMemory"`
+ MaximumMemory *DomainMaxMemory `xml:"maxMemory"`
+ VCPU *DomainVCPU `xml:"vcpu"`
+ Resource *DomainResource `xml:"resource"`
+ SysInfo *DomainSysInfo `xml:"sysinfo"`
+ OS *DomainOS `xml:"os"`
+ Features *DomainFeatureList `xml:"features"`
+ CPU *DomainCPU `xml:"cpu"`
+ OnPoweroff string `xml:"on_poweroff,omitempty"`
+ OnReboot string `xml:"on_reboot,omitempty"`
+ OnCrash string `xml:"on_crash,omitempty"`
+ Devices *DomainDeviceList `xml:"devices"`
+ QEMUCommandline *DomainQEMUCommandline `xml:"qemu commandline"`
}
func (d *Domain) Unmarshal(doc string) error {
diff --git a/domain_test.go b/domain_test.go
index 47e5e26..7e683a9 100644
--- a/domain_test.go
+++ b/domain_test.go
@@ -1141,6 +1141,26 @@ var domainTestData = []struct {
`</domain>`,
},
},
+ {
+ Object: &Domain{
+ Type: "qemu",
+ Name: "test",
+ XMLNS_QEMU: "http://libvirt.org/schemas/domain/qemu/1.0",
+ QEMUCommandline: &DomainQEMUCommandline{
+ Arg: DomainQEMUCommandlineArg{Value: "-newarg"},
+ Env: DomainQEMUCommandlineEnv{Name: "QEMU_ENV", Value: "VAL"},
+ },
+ },
+ Expected: []string{
+ `<domain xmlns:_xmlns="xmlns" _xmlns:qemu="http://libvirt.org/schemas/domain/qemu/1.0" type="qemu">`,
+ ` <name>test</name>`,
+ ` <commandline xmlns="qemu">`,
+ ` <arg xmlns="qemu" value="-newarg"></arg>`,
+ ` <env xmlns="qemu" name="QEMU_ENV" value="VAL"></env>`,
+ ` </commandline>`,
+ `</domain>`,
+ },
+ },
/* Tests for sub-documents that can be hotplugged */
{
--
2.13.2
7 years, 5 months
[libvirt] [PATCH] qemu: domain: Add missing newline to last element in status XML formatter
by Peter Krempa
Commit f9758109a7 did not put a newline after the element it added.
---
Pushed as trivial.
src/qemu/qemu_domain.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 8e7404da6..9a8ae26ac 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -1886,7 +1886,7 @@ qemuDomainObjPrivateXMLFormat(virBufferPtr buf,
virCPUDefFormatBufFull(buf, priv->origCPU, NULL, false);
if (priv->chardevStdioLogd)
- virBufferAddLit(buf, "<chardevStdioLogd/>");
+ virBufferAddLit(buf, "<chardevStdioLogd/>\n");
return 0;
}
--
2.12.2
7 years, 5 months
[libvirt] [PATCH] qemu: Use iohelper during restore
by Shivaprasad G Bhat
Commit afe6e58 & c4caab53 made necessary changes to use io-helpers
during save and restore. The commit c4caab53 missed to remove the
redundant check in qemuDomainSaveImageOpen() because of which
virFileWrapperFdNew() is not called if bypass_cache is false.
Signed-off-by: Shivaprasad G Bhat <sbhat(a)linux.vnet.ibm.com>
---
src/qemu/qemu_driver.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 516a851..ac89372 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -6150,9 +6150,11 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver,
virDomainDefPtr def = NULL;
int oflags = open_write ? O_RDWR : O_RDONLY;
virCapsPtr caps = NULL;
+ unsigned int wrapperFlags = VIR_FILE_WRAPPER_NON_BLOCKING;
if (bypass_cache) {
int directFlag = virFileDirectFdFlag();
+ wrapperFlags |= VIR_FILE_WRAPPER_BYPASS_CACHE;
if (directFlag < 0) {
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("bypass cache unsupported by this system"));
@@ -6166,9 +6168,8 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver,
if ((fd = qemuOpenFile(driver, NULL, path, oflags, NULL, NULL)) < 0)
goto error;
- if (bypass_cache &&
- !(*wrapperFd = virFileWrapperFdNew(&fd, path,
- VIR_FILE_WRAPPER_BYPASS_CACHE)))
+ if (wrapperFd &&
+ !(*wrapperFd = virFileWrapperFdNew(&fd, path, wrapperFlags)))
goto error;
if (saferead(fd, &header, sizeof(header)) != sizeof(header)) {
7 years, 5 months