[libvirt] [PATCH] qemu: process: Save vcpu ordering information on reconnect
by Peter Krempa
vCPU ordering information would not be updated if a vCPU emerged or
disappeared during the time libvirtd is not running. This allowed to
create invalid configuration like:
[...]
<vcpu id='56' enabled='yes' hotpluggable='yes' order='57'/>
<vcpu id='57' enabled='yes' hotpluggable='yes' order='58'/>
<vcpu id='58' enabled='yes' hotpluggable='yes'/>
Call the function that records the information on reconnect.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1451251
---
src/qemu/qemu_process.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index be031b56b..32ba8e373 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -3492,6 +3492,8 @@ qemuProcessReconnect(void *opaque)
if (qemuDomainRefreshVcpuInfo(driver, obj, QEMU_ASYNC_JOB_NONE, true) < 0)
goto error;
+ qemuDomainVcpuPersistOrder(obj->def);
+
if (qemuSecurityReserveLabel(driver->securityManager, obj->def, obj->pid) < 0)
goto error;
--
2.12.2
7 years, 6 months
[libvirt] [PATCH] Report more correct information for cache control
by Martin Kletzander
On some platforms the number of bits in the cbm_mask might not be
divisible by 4 (and not even by 2), so we need to properly count the
bits. Similar file, min_cbm_bits, is properly parsed and used, but if
the number is greater than one, we lose the information about
granularity when reporting the data in capabilities. For that matter
always report granularity, but if it is not the same as the minimum,
add that information in there as well.
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
docs/schemas/capability.rng | 7 ++++-
src/conf/capabilities.c | 34 ++++++++++++++++++----
src/conf/capabilities.h | 1 +
.../linux-resctrl-skx/resctrl/info/L3/cbm_mask | 1 +
.../linux-resctrl-skx/resctrl/info/L3/min_cbm_bits | 1 +
.../linux-resctrl-skx/resctrl/info/L3/num_closids | 1 +
.../linux-resctrl-skx/resctrl/schemata | 1 +
.../system/cpu/cpu0/cache/index0/id | 1 +
.../system/cpu/cpu0/cache/index0/level | 1 +
.../system/cpu/cpu0/cache/index0/shared_cpu_list | 1 +
.../system/cpu/cpu0/cache/index0/shared_cpu_map | 1 +
.../system/cpu/cpu0/cache/index0/size | 1 +
.../system/cpu/cpu0/cache/index0/type | 1 +
.../linux-resctrl-skx/system/cpu/cpu0/online | 1 +
.../system/cpu/cpu0/topology/core_id | 1 +
.../system/cpu/cpu0/topology/core_siblings | 1 +
.../system/cpu/cpu0/topology/core_siblings_list | 1 +
.../system/cpu/cpu0/topology/physical_package_id | 1 +
.../system/cpu/cpu0/topology/thread_siblings | 1 +
.../system/cpu/cpu0/topology/thread_siblings_list | 1 +
.../linux-resctrl-skx/system/cpu/online | 1 +
.../linux-resctrl-skx/system/cpu/present | 1 +
.../linux-resctrl-skx/system/node/node0/cpu0 | 1 +
.../linux-resctrl-skx/system/node/node0/cpulist | 1 +
.../linux-resctrl-skx/system/node/node0/cpumap | 1 +
.../linux-resctrl-skx/system/node/node0/distance | 1 +
.../linux-resctrl-skx/system/node/online | 1 +
.../vircaps2xmldata/vircaps-x86_64-resctrl-cdp.xml | 8 ++---
.../vircaps2xmldata/vircaps-x86_64-resctrl-skx.xml | 31 ++++++++++++++++++++
tests/vircaps2xmldata/vircaps-x86_64-resctrl.xml | 4 +--
tests/vircaps2xmltest.c | 1 +
31 files changed, 97 insertions(+), 13 deletions(-)
create mode 100644 tests/vircaps2xmldata/linux-resctrl-skx/resctrl/info/L3/cbm_mask
create mode 100644 tests/vircaps2xmldata/linux-resctrl-skx/resctrl/info/L3/min_cbm_bits
create mode 100644 tests/vircaps2xmldata/linux-resctrl-skx/resctrl/info/L3/num_closids
create mode 100644 tests/vircaps2xmldata/linux-resctrl-skx/resctrl/schemata
create mode 100644 tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/cache/index0/id
create mode 100644 tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/cache/index0/level
create mode 100644 tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/cache/index0/shared_cpu_list
create mode 100644 tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/cache/index0/shared_cpu_map
create mode 100644 tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/cache/index0/size
create mode 100644 tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/cache/index0/type
create mode 100644 tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/online
create mode 100644 tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/topology/core_id
create mode 100644 tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/topology/core_siblings
create mode 100644 tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/topology/core_siblings_list
create mode 100644 tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/topology/physical_package_id
create mode 100644 tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/topology/thread_siblings
create mode 100644 tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/topology/thread_siblings_list
create mode 100644 tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/online
create mode 100644 tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/present
create mode 120000 tests/vircaps2xmldata/linux-resctrl-skx/system/node/node0/cpu0
create mode 100644 tests/vircaps2xmldata/linux-resctrl-skx/system/node/node0/cpulist
create mode 100644 tests/vircaps2xmldata/linux-resctrl-skx/system/node/node0/cpumap
create mode 100644 tests/vircaps2xmldata/linux-resctrl-skx/system/node/node0/distance
create mode 100644 tests/vircaps2xmldata/linux-resctrl-skx/system/node/online
create mode 100644 tests/vircaps2xmldata/vircaps-x86_64-resctrl-skx.xml
diff --git a/docs/schemas/capability.rng b/docs/schemas/capability.rng
index e5cbfa362ec0..071090c2d991 100644
--- a/docs/schemas/capability.rng
+++ b/docs/schemas/capability.rng
@@ -273,9 +273,14 @@
</attribute>
<zeroOrMore>
<element name='control'>
- <attribute name='min'>
+ <attribute name='granularity'>
<ref name='unsignedInt'/>
</attribute>
+ <optional>
+ <attribute name='min'>
+ <ref name='unsignedInt'/>
+ </attribute>
+ </optional>
<attribute name='unit'>
<ref name='unit'/>
</attribute>
diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c
index 3becc7e18c62..0f99f3096292 100644
--- a/src/conf/capabilities.c
+++ b/src/conf/capabilities.c
@@ -31,6 +31,7 @@
#include <unistd.h>
#include "capabilities.h"
+#include "c-ctype.h"
#include "count-one-bits.h"
#include "cpu_conf.h"
#include "domain_conf.h"
@@ -906,11 +907,24 @@ virCapabilitiesFormatCaches(virBufferPtr buf,
virBufferAdjustIndent(&controlBuf, indent + 4);
for (j = 0; j < bank->ncontrols; j++) {
- bool min_kilos = !(bank->controls[j]->min % 1024);
+ bool min_kilos = !(bank->controls[j]->granularity % 1024);
+
+ /* Only use KiB if both values are divisible */
+ if (bank->controls[j]->min)
+ min_kilos = min_kilos && !(bank->controls[j]->min % 1024);
+
+ virBufferAsprintf(&controlBuf,
+ "<control granularity='%llu'",
+ bank->controls[j]->granularity >> (min_kilos * 10));
+
+ if (bank->controls[j]->min) {
+ virBufferAsprintf(&controlBuf,
+ " min='%llu'",
+ bank->controls[j]->min >> (min_kilos * 10));
+ }
+
virBufferAsprintf(&controlBuf,
- "<control min='%llu' unit='%s' "
- "type='%s' maxAllocs='%u'/>\n",
- bank->controls[j]->min >> (min_kilos * 10),
+ " unit='%s' type='%s' maxAllocs='%u'/>\n",
min_kilos ? "KiB" : "B",
virCacheTypeToString(bank->controls[j]->scope),
bank->controls[j]->max_allocation);
@@ -1598,9 +1612,11 @@ virCapabilitiesGetCacheControl(virCapsHostCacheBankPtr bank,
virCacheType scope)
{
int ret = -1;
+ char *tmp = NULL;
char *path = NULL;
char *cbm_mask = NULL;
char *type_upper = NULL;
+ unsigned int bits = 0;
unsigned int min_cbm_bits = 0;
virCapsHostCacheControlPtr control;
@@ -1632,8 +1648,14 @@ virCapabilitiesGetCacheControl(virCapsHostCacheBankPtr bank,
virStringTrimOptionalNewline(cbm_mask);
- /* cbm_mask: cache bit mask, it's in hex, eg: fffff */
- control->min = min_cbm_bits * bank->size / (strlen(cbm_mask) * 4);
+ for (tmp = cbm_mask; *tmp != '\0'; tmp++) {
+ if (c_isxdigit(*tmp))
+ bits += count_one_bits(virHexToBin(*tmp));
+ }
+
+ control->granularity = bank->size / bits;
+ if (min_cbm_bits != 1)
+ control->min = min_cbm_bits * control->granularity;
control->scope = scope;
diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h
index ee87d598ef66..d4753db0beec 100644
--- a/src/conf/capabilities.h
+++ b/src/conf/capabilities.h
@@ -152,6 +152,7 @@ typedef struct _virCapsHostCacheControl virCapsHostCacheControl;
typedef virCapsHostCacheControl *virCapsHostCacheControlPtr;
struct _virCapsHostCacheControl {
unsigned long long min; /* minimum cache control size in B */
+ unsigned long long granularity; /* minimum increase step for min in B */
virCacheType scope; /* data, code or both */
unsigned int max_allocation; /* max number of supported allocations */
};
diff --git a/tests/vircaps2xmldata/linux-resctrl-skx/resctrl/info/L3/cbm_mask b/tests/vircaps2xmldata/linux-resctrl-skx/resctrl/info/L3/cbm_mask
new file mode 100644
index 000000000000..d482bbb26931
--- /dev/null
+++ b/tests/vircaps2xmldata/linux-resctrl-skx/resctrl/info/L3/cbm_mask
@@ -0,0 +1 @@
+7ff
diff --git a/tests/vircaps2xmldata/linux-resctrl-skx/resctrl/info/L3/min_cbm_bits b/tests/vircaps2xmldata/linux-resctrl-skx/resctrl/info/L3/min_cbm_bits
new file mode 100644
index 000000000000..d00491fd7e5b
--- /dev/null
+++ b/tests/vircaps2xmldata/linux-resctrl-skx/resctrl/info/L3/min_cbm_bits
@@ -0,0 +1 @@
+1
diff --git a/tests/vircaps2xmldata/linux-resctrl-skx/resctrl/info/L3/num_closids b/tests/vircaps2xmldata/linux-resctrl-skx/resctrl/info/L3/num_closids
new file mode 100644
index 000000000000..b6a7d89c68e0
--- /dev/null
+++ b/tests/vircaps2xmldata/linux-resctrl-skx/resctrl/info/L3/num_closids
@@ -0,0 +1 @@
+16
diff --git a/tests/vircaps2xmldata/linux-resctrl-skx/resctrl/schemata b/tests/vircaps2xmldata/linux-resctrl-skx/resctrl/schemata
new file mode 100644
index 000000000000..4a4913735386
--- /dev/null
+++ b/tests/vircaps2xmldata/linux-resctrl-skx/resctrl/schemata
@@ -0,0 +1 @@
+L3:0=7ff;1=7ff
diff --git a/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/cache/index0/id b/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/cache/index0/id
new file mode 100644
index 000000000000..573541ac9702
--- /dev/null
+++ b/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/cache/index0/id
@@ -0,0 +1 @@
+0
diff --git a/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/cache/index0/level b/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/cache/index0/level
new file mode 100644
index 000000000000..00750edc07d6
--- /dev/null
+++ b/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/cache/index0/level
@@ -0,0 +1 @@
+3
diff --git a/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/cache/index0/shared_cpu_list b/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/cache/index0/shared_cpu_list
new file mode 100644
index 000000000000..573541ac9702
--- /dev/null
+++ b/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/cache/index0/shared_cpu_list
@@ -0,0 +1 @@
+0
diff --git a/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/cache/index0/shared_cpu_map b/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/cache/index0/shared_cpu_map
new file mode 100644
index 000000000000..5325a8dff751
--- /dev/null
+++ b/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/cache/index0/shared_cpu_map
@@ -0,0 +1 @@
+001
diff --git a/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/cache/index0/size b/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/cache/index0/size
new file mode 100644
index 000000000000..24a7d60e7fb9
--- /dev/null
+++ b/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/cache/index0/size
@@ -0,0 +1 @@
+11264K
diff --git a/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/cache/index0/type b/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/cache/index0/type
new file mode 100644
index 000000000000..e4fd9dccda2c
--- /dev/null
+++ b/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/cache/index0/type
@@ -0,0 +1 @@
+Unified
diff --git a/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/online b/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/online
new file mode 100644
index 000000000000..d00491fd7e5b
--- /dev/null
+++ b/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/online
@@ -0,0 +1 @@
+1
diff --git a/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/topology/core_id b/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/topology/core_id
new file mode 100644
index 000000000000..573541ac9702
--- /dev/null
+++ b/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/topology/core_id
@@ -0,0 +1 @@
+0
diff --git a/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/topology/core_siblings b/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/topology/core_siblings
new file mode 100644
index 000000000000..5325a8dff751
--- /dev/null
+++ b/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/topology/core_siblings
@@ -0,0 +1 @@
+001
diff --git a/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/topology/core_siblings_list b/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/topology/core_siblings_list
new file mode 100644
index 000000000000..573541ac9702
--- /dev/null
+++ b/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/topology/core_siblings_list
@@ -0,0 +1 @@
+0
diff --git a/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/topology/physical_package_id b/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/topology/physical_package_id
new file mode 100644
index 000000000000..573541ac9702
--- /dev/null
+++ b/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/topology/physical_package_id
@@ -0,0 +1 @@
+0
diff --git a/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/topology/thread_siblings b/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/topology/thread_siblings
new file mode 100644
index 000000000000..5325a8dff751
--- /dev/null
+++ b/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/topology/thread_siblings
@@ -0,0 +1 @@
+001
diff --git a/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/topology/thread_siblings_list b/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/topology/thread_siblings_list
new file mode 100644
index 000000000000..573541ac9702
--- /dev/null
+++ b/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/cpu0/topology/thread_siblings_list
@@ -0,0 +1 @@
+0
diff --git a/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/online b/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/online
new file mode 100644
index 000000000000..573541ac9702
--- /dev/null
+++ b/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/online
@@ -0,0 +1 @@
+0
diff --git a/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/present b/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/present
new file mode 100644
index 000000000000..573541ac9702
--- /dev/null
+++ b/tests/vircaps2xmldata/linux-resctrl-skx/system/cpu/present
@@ -0,0 +1 @@
+0
diff --git a/tests/vircaps2xmldata/linux-resctrl-skx/system/node/node0/cpu0 b/tests/vircaps2xmldata/linux-resctrl-skx/system/node/node0/cpu0
new file mode 120000
index 000000000000..c841bea28b2b
--- /dev/null
+++ b/tests/vircaps2xmldata/linux-resctrl-skx/system/node/node0/cpu0
@@ -0,0 +1 @@
+../../cpu/cpu0
\ No newline at end of file
diff --git a/tests/vircaps2xmldata/linux-resctrl-skx/system/node/node0/cpulist b/tests/vircaps2xmldata/linux-resctrl-skx/system/node/node0/cpulist
new file mode 100644
index 000000000000..573541ac9702
--- /dev/null
+++ b/tests/vircaps2xmldata/linux-resctrl-skx/system/node/node0/cpulist
@@ -0,0 +1 @@
+0
diff --git a/tests/vircaps2xmldata/linux-resctrl-skx/system/node/node0/cpumap b/tests/vircaps2xmldata/linux-resctrl-skx/system/node/node0/cpumap
new file mode 100644
index 000000000000..5325a8dff751
--- /dev/null
+++ b/tests/vircaps2xmldata/linux-resctrl-skx/system/node/node0/cpumap
@@ -0,0 +1 @@
+001
diff --git a/tests/vircaps2xmldata/linux-resctrl-skx/system/node/node0/distance b/tests/vircaps2xmldata/linux-resctrl-skx/system/node/node0/distance
new file mode 100644
index 000000000000..f599e28b8ab0
--- /dev/null
+++ b/tests/vircaps2xmldata/linux-resctrl-skx/system/node/node0/distance
@@ -0,0 +1 @@
+10
diff --git a/tests/vircaps2xmldata/linux-resctrl-skx/system/node/online b/tests/vircaps2xmldata/linux-resctrl-skx/system/node/online
new file mode 100644
index 000000000000..573541ac9702
--- /dev/null
+++ b/tests/vircaps2xmldata/linux-resctrl-skx/system/node/online
@@ -0,0 +1 @@
+0
diff --git a/tests/vircaps2xmldata/vircaps-x86_64-resctrl-cdp.xml b/tests/vircaps2xmldata/vircaps-x86_64-resctrl-cdp.xml
index 49aa0b98ca88..7361537bfb56 100644
--- a/tests/vircaps2xmldata/vircaps-x86_64-resctrl-cdp.xml
+++ b/tests/vircaps2xmldata/vircaps-x86_64-resctrl-cdp.xml
@@ -42,12 +42,12 @@
</topology>
<cache>
<bank id='0' level='3' type='both' size='15360' unit='KiB' cpus='0-5'>
- <control min='768' unit='KiB' type='code' maxAllocs='8'/>
- <control min='768' unit='KiB' type='data' maxAllocs='8'/>
+ <control granularity='768' unit='KiB' type='code' maxAllocs='8'/>
+ <control granularity='768' unit='KiB' type='data' maxAllocs='8'/>
</bank>
<bank id='1' level='3' type='both' size='15360' unit='KiB' cpus='6-11'>
- <control min='768' unit='KiB' type='code' maxAllocs='8'/>
- <control min='768' unit='KiB' type='data' maxAllocs='8'/>
+ <control granularity='768' unit='KiB' type='code' maxAllocs='8'/>
+ <control granularity='768' unit='KiB' type='data' maxAllocs='8'/>
</bank>
</cache>
</host>
diff --git a/tests/vircaps2xmldata/vircaps-x86_64-resctrl-skx.xml b/tests/vircaps2xmldata/vircaps-x86_64-resctrl-skx.xml
new file mode 100644
index 000000000000..f582581148f7
--- /dev/null
+++ b/tests/vircaps2xmldata/vircaps-x86_64-resctrl-skx.xml
@@ -0,0 +1,31 @@
+<capabilities>
+
+ <host>
+ <cpu>
+ <arch>x86_64</arch>
+ </cpu>
+ <power_management/>
+ <migration_features>
+ <live/>
+ </migration_features>
+ <topology>
+ <cells num='1'>
+ <cell id='0'>
+ <memory unit='KiB'>1048576</memory>
+ <pages unit='KiB' size='4'>2048</pages>
+ <pages unit='KiB' size='2048'>4096</pages>
+ <pages unit='KiB' size='1048576'>6144</pages>
+ <cpus num='1'>
+ <cpu id='0' socket_id='0' core_id='0' siblings='0'/>
+ </cpus>
+ </cell>
+ </cells>
+ </topology>
+ <cache>
+ <bank id='0' level='3' type='both' size='11264' unit='KiB' cpus='0'>
+ <control granularity='1024' unit='KiB' type='both' maxAllocs='16'/>
+ </bank>
+ </cache>
+ </host>
+
+</capabilities>
diff --git a/tests/vircaps2xmldata/vircaps-x86_64-resctrl.xml b/tests/vircaps2xmldata/vircaps-x86_64-resctrl.xml
index cb78b4ab788d..eb02ad3322a2 100644
--- a/tests/vircaps2xmldata/vircaps-x86_64-resctrl.xml
+++ b/tests/vircaps2xmldata/vircaps-x86_64-resctrl.xml
@@ -42,10 +42,10 @@
</topology>
<cache>
<bank id='0' level='3' type='both' size='15360' unit='KiB' cpus='0-5'>
- <control min='1536' unit='KiB' type='both' maxAllocs='4'/>
+ <control granularity='768' min='1536' unit='KiB' type='both' maxAllocs='4'/>
</bank>
<bank id='1' level='3' type='both' size='15360' unit='KiB' cpus='6-11'>
- <control min='1536' unit='KiB' type='both' maxAllocs='4'/>
+ <control granularity='768' min='1536' unit='KiB' type='both' maxAllocs='4'/>
</bank>
</cache>
</host>
diff --git a/tests/vircaps2xmltest.c b/tests/vircaps2xmltest.c
index ae1cd521111e..c0a67858fec3 100644
--- a/tests/vircaps2xmltest.c
+++ b/tests/vircaps2xmltest.c
@@ -120,6 +120,7 @@ mymain(void)
DO_TEST_FULL("resctrl", VIR_ARCH_X86_64, true, true, true);
DO_TEST_FULL("resctrl-cdp", VIR_ARCH_X86_64, true, true, true);
+ DO_TEST_FULL("resctrl-skx", VIR_ARCH_X86_64, true, true, true);
return ret;
}
--
2.13.0
7 years, 6 months
[libvirt] [PATCH] lxc: allow defining environment variables
by Cédric Bosdonnat
When running an application container, setting environment variables
could be important.
The newly introduced <initenv> tag in domain configuration will allow
setting environment variables to the init program.
---
docs/formatdomain.html.in | 5 +++++
docs/schemas/domaincommon.rng | 10 ++++++++++
src/conf/domain_conf.c | 38 ++++++++++++++++++++++++++++++++++++
src/conf/domain_conf.h | 8 ++++++++
src/lxc/lxc_container.c | 5 +++++
tests/lxcxml2xmldata/lxc-initenv.xml | 30 ++++++++++++++++++++++++++++
tests/lxcxml2xmltest.c | 1 +
7 files changed, 97 insertions(+)
create mode 100644 tests/lxcxml2xmldata/lxc-initenv.xml
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 07208eef8..8da50875b 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -326,6 +326,10 @@
element, if set will be used to provide an equivalent to <code>/proc/cmdline</code>
but will not affect init argv.
</p>
+ <p>
+ To set environment variables, use the <code>initenv</code> element, one
+ for each variable.
+ </p>
<pre>
<os>
@@ -333,6 +337,7 @@
<init>/bin/systemd</init>
<initarg>--unit</initarg>
<initarg>emergency.service</initarg>
+ <initenv name='MYENV'>some value</initenv>
</os>
</pre>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 4d9f8d1a2..695214816 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -385,6 +385,16 @@
<text/>
</element>
</zeroOrMore>
+ <zeroOrMore>
+ <element name="initenv">
+ <attribute name="name">
+ <data type='string'>
+ <param name='pattern'>[a-zA-Z_]+[a-zA-Z0-9_]*</param>
+ </data>
+ </attribute>
+ <text/>
+ </element>
+ </zeroOrMore>
</interleave>
</element>
</define>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index c7e20b8ba..89c803047 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -2799,6 +2799,9 @@ void virDomainDefFree(virDomainDefPtr def)
for (i = 0; def->os.initargv && def->os.initargv[i]; i++)
VIR_FREE(def->os.initargv[i]);
VIR_FREE(def->os.initargv);
+ for (i = 0; def->os.initenv && def->os.initenv[i]; i++)
+ VIR_FREE(def->os.initenv[i]);
+ VIR_FREE(def->os.initenv);
VIR_FREE(def->os.kernel);
VIR_FREE(def->os.initrd);
VIR_FREE(def->os.cmdline);
@@ -16776,6 +16779,7 @@ virDomainDefParseBootOptions(virDomainDefPtr def,
xmlNodePtr *nodes = NULL;
xmlNodePtr oldnode;
char *tmp = NULL;
+ char *name = NULL;
int ret = -1;
size_t i;
int n;
@@ -16811,6 +16815,37 @@ virDomainDefParseBootOptions(virDomainDefPtr def,
}
def->os.initargv[n] = NULL;
VIR_FREE(nodes);
+
+ if ((n = virXPathNodeSet("./os/initenv", ctxt, &nodes)) < 0)
+ goto error;
+
+ if (VIR_ALLOC_N(def->os.initenv, n+1) < 0)
+ goto error;
+ for (i = 0; i < n; i++) {
+ if (!(name = virXMLPropString(nodes[i], "name"))) {
+ virReportError(VIR_ERR_XML_ERROR, "%s",
+ _("No name supplied for <initenv> element"));
+ goto error;
+ }
+
+ if (!nodes[i]->children ||
+ !nodes[i]->children->content) {
+ virReportError(VIR_ERR_XML_ERROR,
+ _("No value supplied for <initenv name='%s'> element"),
+ name);
+ goto error;
+ }
+
+ if (VIR_ALLOC(def->os.initenv[i]) < 0)
+ goto error;
+
+ def->os.initenv[i]->name = name;
+ if (VIR_STRDUP(def->os.initenv[i]->value,
+ (const char*) nodes[i]->children->content) < 0)
+ goto error;
+ }
+ def->os.initenv[n] = NULL;
+ VIR_FREE(nodes);
}
if (def->os.type == VIR_DOMAIN_OSTYPE_XEN ||
@@ -24524,6 +24559,9 @@ virDomainDefFormatInternal(virDomainDefPtr def,
for (i = 0; def->os.initargv && def->os.initargv[i]; i++)
virBufferEscapeString(buf, "<initarg>%s</initarg>\n",
def->os.initargv[i]);
+ for (i = 0; def->os.initenv && def->os.initenv[i]; i++)
+ virBufferAsprintf(buf, "<initenv name='%s'>%s</initenv>\n",
+ def->os.initenv[i]->name, def->os.initenv[i]->value);
if (def->os.loader)
virDomainLoaderDefFormat(buf, def->os.loader);
virBufferEscapeString(buf, "<kernel>%s</kernel>\n",
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 83e067269..03153b972 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1820,6 +1820,13 @@ typedef enum {
VIR_ENUM_DECL(virDomainIOAPIC);
/* Operating system configuration data & machine / arch */
+typedef struct _virDomainOSEnv virDomainOSEnv;
+typedef virDomainOSEnv *virDomainOSEnvPtr;
+struct _virDomainOSEnv {
+ char *name;
+ char *value;
+};
+
typedef struct _virDomainOSDef virDomainOSDef;
typedef virDomainOSDef *virDomainOSDefPtr;
struct _virDomainOSDef {
@@ -1833,6 +1840,7 @@ struct _virDomainOSDef {
bool bm_timeout_set;
char *init;
char **initargv;
+ virDomainOSEnvPtr *initenv;
char *kernel;
char *initrd;
char *cmdline;
diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index af02b5460..ffafc39d7 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -246,6 +246,11 @@ static virCommandPtr lxcContainerBuildInitCmd(virDomainDefPtr vmDef,
if (vmDef->os.cmdline)
virCommandAddEnvPair(cmd, "LIBVIRT_LXC_CMDLINE", vmDef->os.cmdline);
+ for (i = 0; vmDef->os.initenv[i]; i++) {
+ virCommandAddEnvPair(cmd, vmDef->os.initenv[i]->name,
+ vmDef->os.initenv[i]->value);
+ }
+
virBufferFreeAndReset(&buf);
return cmd;
}
diff --git a/tests/lxcxml2xmldata/lxc-initenv.xml b/tests/lxcxml2xmldata/lxc-initenv.xml
new file mode 100644
index 000000000..933d836a2
--- /dev/null
+++ b/tests/lxcxml2xmldata/lxc-initenv.xml
@@ -0,0 +1,30 @@
+<domain type='lxc'>
+ <name>jessie</name>
+ <uuid>e21987a5-e98e-9c99-0e35-803e4d9ad1fe</uuid>
+ <memory unit='KiB'>1048576</memory>
+ <currentMemory unit='KiB'>1048576</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <resource>
+ <partition>/machine</partition>
+ </resource>
+ <os>
+ <type arch='x86_64'>exe</type>
+ <init>/sbin/sh</init>
+ <initenv name='FOO'>bar</initenv>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>restart</on_crash>
+ <devices>
+ <emulator>/usr/libexec/libvirt_lxc</emulator>
+ <filesystem type='mount' accessmode='passthrough'>
+ <source dir='/mach/jessie'/>
+ <target dir='/'/>
+ </filesystem>
+ <console type='pty'>
+ <target type='lxc' port='0'/>
+ </console>
+ </devices>
+ <seclabel type='none'/>
+</domain>
diff --git a/tests/lxcxml2xmltest.c b/tests/lxcxml2xmltest.c
index 226a73d27..2a24b60b3 100644
--- a/tests/lxcxml2xmltest.c
+++ b/tests/lxcxml2xmltest.c
@@ -98,6 +98,7 @@ mymain(void)
DO_TEST("ethernet-hostip");
DO_TEST_FULL("filesystem-root", 0, false,
VIR_DOMAIN_DEF_PARSE_SKIP_OSTYPE_CHECKS);
+ DO_TEST("initenv");
virObjectUnref(caps);
virObjectUnref(xmlopt);
--
2.12.2
7 years, 6 months
[libvirt] [PATCH 0/2] Set lxc container working directory
by Cédric Bosdonnat
Hi all,
To get lxc containers set the workng directory I had to refactor
virExec and virCommandExec to share some more code.
Cédric Bosdonnat (2):
util: share code between virExec and virCommandExec
lxc: allow user to specify command working directory
docs/formatdomain.html.in | 5 ++
docs/schemas/domaincommon.rng | 5 ++
src/conf/domain_conf.c | 5 ++
src/conf/domain_conf.h | 1 +
src/lxc/lxc_container.c | 4 +-
src/util/vircommand.c | 92 +++++++++++++++++-------------------
tests/lxcxml2xmldata/lxc-initdir.xml | 30 ++++++++++++
tests/lxcxml2xmltest.c | 1 +
8 files changed, 93 insertions(+), 50 deletions(-)
create mode 100644 tests/lxcxml2xmldata/lxc-initdir.xml
--
2.12.2
7 years, 6 months
[libvirt] [ISSUE go-xml] go-xml does NOT support DomainDisk marshal
by ZhenweiPi
Hi,
In the case of disk hot-plug, we need a xml like this :
/<disk type="file" device="disk">//
// <driver name="qemu" type="qcow2"/>//
// <source file="/root/vda.qcow2"/>//
// <target dev="vda" bus="virtio"/>//
// <address type='pci' domain='0x0000' bus='1' slot='20' function='0x0'/>//
//</disk>/
For now, go-xml does not support DomainDisk marshal.
Any good idea ?
7 years, 6 months
[libvirt] [PATCH v4 0/3] Multiple cleanups within interfaceobj and interface driver
by John Ferlan
v3: https://www.redhat.com/archives/libvir-list/2017-May/msg01161.html
NB: The first 7 patches from v3 were pushed since they were ACK'd.
Difference in v4:
Patch 1 was essentially ACK'd, but I chose to hold onto it to show the context
Patch 2 is the new patch/context - move the @def processing into ObjNew
Patch 3 is mostly unchanged; however, I realized during processing of the
other code that with the model chosen in virInterfaceObjListAssignDef
to return an object that has had both the @lock and @ref incremented
so that callers can use the EndAPI to effectively Unlock and Unref
that means when calling virInterfaceObjListRemove all that's done
is a single Unlock/Unref leaving the object with still 1 reference
(and undeleted). That means the caller (testInterfaceUndefine)
must make that Unref call of the object. This is no different
than how Domain's work, although it's a bit more obtuse there because
callers of domain add will make that "second" reference to the object
and my goal in this is to be a bit more obvious...
The easier way to think about this is for objects only in one list,
when leaving the Add/Assign API's, there are 2 Refs and 1 Lock on
the object. For objects in 2 lists, there are 3 Refs and 1 Lock.
Each caller always calls EndAPI dropping a Ref and the Lock. When
it's time to Remove the object, a Find is done - which increments
a Ref and Lock and then the Remove API called. The Remove API will
effectively Unref for the object in a list (once or twice) and return
the Unlocked object w/ 1 Ref.
John Ferlan (3):
interface: Introduce virInterfaceObjNew
interface: Consume @def in virInterfaceObjNew
interface: Convert virInterfaceObj to use virObjectLockable
po/POTFILES.in | 1 -
src/conf/virinterfaceobj.c | 108 +++++++++++++++++++++++++++------------------
src/conf/virinterfaceobj.h | 9 ++--
src/libvirt_private.syms | 3 +-
src/test/test_driver.c | 16 +++----
5 files changed, 77 insertions(+), 60 deletions(-)
--
2.9.4
7 years, 6 months
[libvirt] [PATCH] audit: Fix the output message for shmem
by Martin Kletzander
After some discussion on and off the linux-audit mailing list, we
should use different fields for the audit messages.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1218603
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
src/conf/domain_audit.c | 24 +++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/src/conf/domain_audit.c b/src/conf/domain_audit.c
index 2d9ff5e3ffea..1e667af73c4f 100644
--- a/src/conf/domain_audit.c
+++ b/src/conf/domain_audit.c
@@ -983,15 +983,13 @@ virDomainAuditShmem(virDomainObjPtr vm,
char uuidstr[VIR_UUID_STRING_BUFLEN];
char *vmname = virAuditEncode("vm", vm->def->name);
const char *srcpath = virDomainAuditChardevPath(&def->server.chr);
- char *src = virAuditEncode("server", VIR_AUDIT_STR(srcpath));
- char *shmem = virAuditEncode("shmem", VIR_AUDIT_STR(def->name));
const char *virt = virDomainVirtTypeToString(vm->def->virtType);
- char *size = NULL;
+ char *shmpath = NULL;
virUUIDFormat(vm->def->uuid, uuidstr);
- if (!vmname || !src || !shmem ||
- virAsprintfQuiet(&size, "%llu", def->size) < 0) {
+ if (!vmname ||
+ virAsprintfQuiet(&shmpath, "/dev/shm/%s", def->name) < 0) {
VIR_WARN("OOM while encoding audit message");
goto cleanup;
}
@@ -1002,14 +1000,18 @@ virDomainAuditShmem(virDomainObjPtr vm,
virt = "?";
}
- VIR_AUDIT(VIR_AUDIT_RECORD_RESOURCE, success,
- "virt=%s resrc=shmem reason=%s %s uuid=%s size=%s %s %s",
- virt, reason, vmname, uuidstr, size, shmem, src);
+ if (def->server.enabled) {
+ VIR_AUDIT(VIR_AUDIT_RECORD_RESOURCE, success,
+ "virt=%s resrc=ivshmem-socket reason=%s %s uuid=%s path=%s",
+ virt, reason, vmname, uuidstr, VIR_AUDIT_STR(srcpath));
+ } else {
+ VIR_AUDIT(VIR_AUDIT_RECORD_RESOURCE, success,
+ "virt=%s resrc=shmem reason=%s %s uuid=%s size=%llu path=%s",
+ virt, reason, vmname, uuidstr, def->size, VIR_AUDIT_STR(shmpath));
+ }
cleanup:
VIR_FREE(vmname);
- VIR_FREE(src);
- VIR_FREE(size);
- VIR_FREE(shmem);
+ VIR_FREE(shmpath);
return;
}
--
2.13.0
7 years, 6 months
[libvirt] [PATCH] Capabilities: add step to cache control
by Eli Qiao
This patch adds cache control step size under control tag.
step is calculated by total_cache_size / cbm_length. This will be needed
while later doing cache allocation to calculate cbm bits.
Besides, count host's cbm length by counting bit instead of checking
cbm_mask length, along with test case updated.
Signed-off-by: Eli Qiao <qiaoliyong(a)gmail.com>
---
docs/schemas/capability.rng | 3 +++
src/conf/capabilities.c | 19 ++++++++++++++++---
src/conf/capabilities.h | 1 +
.../linux-resctrl/resctrl/info/L3/cbm_mask | 2 +-
.../linux-resctrl/resctrl/info/L3/min_cbm_bits | 2 +-
.../linux-resctrl/resctrl/info/L3/num_closids | 2 +-
tests/vircaps2xmldata/vircaps-x86_64-resctrl-cdp.xml | 8 ++++----
tests/vircaps2xmldata/vircaps-x86_64-resctrl.xml | 4 ++--
8 files changed, 29 insertions(+), 12 deletions(-)
diff --git a/docs/schemas/capability.rng b/docs/schemas/capability.rng
index e5cbfa3..6be7ac9 100644
--- a/docs/schemas/capability.rng
+++ b/docs/schemas/capability.rng
@@ -276,6 +276,9 @@
<attribute name='min'>
<ref name='unsignedInt'/>
</attribute>
+ <attribute name='step'>
+ <ref name='unsignedInt'/>
+ </attribute>
<attribute name='unit'>
<ref name='unit'/>
</attribute>
diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c
index 3becc7e..d1266e6 100644
--- a/src/conf/capabilities.c
+++ b/src/conf/capabilities.c
@@ -908,9 +908,10 @@ virCapabilitiesFormatCaches(virBufferPtr buf,
for (j = 0; j < bank->ncontrols; j++) {
bool min_kilos = !(bank->controls[j]->min % 1024);
virBufferAsprintf(&controlBuf,
- "<control min='%llu' unit='%s' "
+ "<control min='%llu' step='%llu' unit='%s' "
"type='%s' maxAllocs='%u'/>\n",
bank->controls[j]->min >> (min_kilos * 10),
+ bank->controls[j]->step >> (min_kilos * 10),
min_kilos ? "KiB" : "B",
virCacheTypeToString(bank->controls[j]->scope),
bank->controls[j]->max_allocation);
@@ -1602,6 +1603,8 @@ virCapabilitiesGetCacheControl(virCapsHostCacheBankPtr bank,
char *cbm_mask = NULL;
char *type_upper = NULL;
unsigned int min_cbm_bits = 0;
+ unsigned int cbm_mask_val = 0;
+ unsigned int cbm_mask_len = 0;
virCapsHostCacheControlPtr control;
if (VIR_ALLOC(control) < 0)
@@ -1632,8 +1635,18 @@ virCapabilitiesGetCacheControl(virCapsHostCacheBankPtr bank,
virStringTrimOptionalNewline(cbm_mask);
- /* cbm_mask: cache bit mask, it's in hex, eg: fffff */
- control->min = min_cbm_bits * bank->size / (strlen(cbm_mask) * 4);
+ /* cbm_mask: cache bit mask, it's in hex, e.g. fffff or 7ff */
+ if (virStrToLong_uip(cbm_mask, NULL, 16, &cbm_mask_val) < 0)
+ goto cleanup;
+
+ while (cbm_mask_val & 0x1) {
+ cbm_mask_val = cbm_mask_val >> 1;
+ cbm_mask_len ++;
+ }
+
+ control->step = bank->size / cbm_mask_len;
+
+ control->min = min_cbm_bits * control->step;
control->scope = scope;
diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h
index ee87d59..2cc9bdc 100644
--- a/src/conf/capabilities.h
+++ b/src/conf/capabilities.h
@@ -152,6 +152,7 @@ typedef struct _virCapsHostCacheControl virCapsHostCacheControl;
typedef virCapsHostCacheControl *virCapsHostCacheControlPtr;
struct _virCapsHostCacheControl {
unsigned long long min; /* minimum cache control size in B */
+ unsigned long long step; /* cache control step size in B */
virCacheType scope; /* data, code or both */
unsigned int max_allocation; /* max number of supported allocations */
};
diff --git a/tests/vircaps2xmldata/linux-resctrl/resctrl/info/L3/cbm_mask b/tests/vircaps2xmldata/linux-resctrl/resctrl/info/L3/cbm_mask
index 78031da..d482bbb 100644
--- a/tests/vircaps2xmldata/linux-resctrl/resctrl/info/L3/cbm_mask
+++ b/tests/vircaps2xmldata/linux-resctrl/resctrl/info/L3/cbm_mask
@@ -1 +1 @@
-fffff
+7ff
diff --git a/tests/vircaps2xmldata/linux-resctrl/resctrl/info/L3/min_cbm_bits b/tests/vircaps2xmldata/linux-resctrl/resctrl/info/L3/min_cbm_bits
index 0cfbf08..d00491f 100644
--- a/tests/vircaps2xmldata/linux-resctrl/resctrl/info/L3/min_cbm_bits
+++ b/tests/vircaps2xmldata/linux-resctrl/resctrl/info/L3/min_cbm_bits
@@ -1 +1 @@
-2
+1
diff --git a/tests/vircaps2xmldata/linux-resctrl/resctrl/info/L3/num_closids b/tests/vircaps2xmldata/linux-resctrl/resctrl/info/L3/num_closids
index b8626c4..b6a7d89 100644
--- a/tests/vircaps2xmldata/linux-resctrl/resctrl/info/L3/num_closids
+++ b/tests/vircaps2xmldata/linux-resctrl/resctrl/info/L3/num_closids
@@ -1 +1 @@
-4
+16
diff --git a/tests/vircaps2xmldata/vircaps-x86_64-resctrl-cdp.xml b/tests/vircaps2xmldata/vircaps-x86_64-resctrl-cdp.xml
index 49aa0b9..98893b6 100644
--- a/tests/vircaps2xmldata/vircaps-x86_64-resctrl-cdp.xml
+++ b/tests/vircaps2xmldata/vircaps-x86_64-resctrl-cdp.xml
@@ -42,12 +42,12 @@
</topology>
<cache>
<bank id='0' level='3' type='both' size='15360' unit='KiB' cpus='0-5'>
- <control min='768' unit='KiB' type='code' maxAllocs='8'/>
- <control min='768' unit='KiB' type='data' maxAllocs='8'/>
+ <control min='768' step='768' unit='KiB' type='code' maxAllocs='8'/>
+ <control min='768' step='768' unit='KiB' type='data' maxAllocs='8'/>
</bank>
<bank id='1' level='3' type='both' size='15360' unit='KiB' cpus='6-11'>
- <control min='768' unit='KiB' type='code' maxAllocs='8'/>
- <control min='768' unit='KiB' type='data' maxAllocs='8'/>
+ <control min='768' step='768' unit='KiB' type='code' maxAllocs='8'/>
+ <control min='768' step='768' unit='KiB' type='data' maxAllocs='8'/>
</bank>
</cache>
</host>
diff --git a/tests/vircaps2xmldata/vircaps-x86_64-resctrl.xml b/tests/vircaps2xmldata/vircaps-x86_64-resctrl.xml
index cb78b4a..b54f08e 100644
--- a/tests/vircaps2xmldata/vircaps-x86_64-resctrl.xml
+++ b/tests/vircaps2xmldata/vircaps-x86_64-resctrl.xml
@@ -42,10 +42,10 @@
</topology>
<cache>
<bank id='0' level='3' type='both' size='15360' unit='KiB' cpus='0-5'>
- <control min='1536' unit='KiB' type='both' maxAllocs='4'/>
+ <control min='1429876' step='1429876' unit='B' type='both' maxAllocs='16'/>
</bank>
<bank id='1' level='3' type='both' size='15360' unit='KiB' cpus='6-11'>
- <control min='1536' unit='KiB' type='both' maxAllocs='4'/>
+ <control min='1429876' step='1429876' unit='B' type='both' maxAllocs='16'/>
</bank>
</cache>
</host>
--
1.9.1
7 years, 6 months
[libvirt] [PATCH go-xml] add emulator supported
by zhenwei.pi
---
domain.go | 1 +
domain_test.go | 6 ++++++
2 files changed, 7 insertions(+)
diff --git a/domain.go b/domain.go
index dcb8f65..723e761 100644
--- a/domain.go
+++ b/domain.go
@@ -307,6 +307,7 @@ type DomainDeviceList struct {
Channels []DomainChardev `xml:"channel"`
MemBalloon *DomainMemBalloon `xml:"memballoon"`
Sounds []DomainSound `xml:"sound"`
+ Emulator string `xml:"emulator,omitempty"`
}
type DomainMemory struct {
diff --git a/domain_test.go b/domain_test.go
index 632b714..9efbd6b 100644
--- a/domain_test.go
+++ b/domain_test.go
@@ -572,6 +572,9 @@ var domainTestData = []struct {
DomainCPUFeature{Policy: "disable", Name: "lahf_lm"},
},
},
+ Devices: &DomainDeviceList{
+ Emulator: "/bin/qemu-kvm",
+ },
},
Expected: []string{
`<domain type="kvm">`,
@@ -582,6 +585,9 @@ var domainTestData = []struct {
` <topology sockets="1" cores="2" threads="1"></topology>`,
` <feature policy="disable" name="lahf_lm"></feature>`,
` </cpu>`,
+ ` <devices>`,
+ ` <emulator>/bin/qemu-kvm</emulator>`,
+ ` </devices>`,
`</domain>`,
},
},
--
2.7.4
7 years, 6 months