[libvirt] [PATCH] Add new 'kvm' domain feature and ability to hide KVM signature
by Alex Williamson
QEMU 2.1 added support for the kvm=off option to the -cpu command,
allowing the KVM hypervisor signature to be hidden from the guest.
This enables disabling of some paravirualization features in the
guest as well as allowing certain drivers which test for the
hypervisor to load. Domain XML syntax is as follows:
<domain type='kvm>
...
<features>
...
<kvm>
<hidden state='on'/>
</kvm>
</features>
...
Signed-off-by: Alex Williamson <alex.williamson(a)redhat.com>
---
If it's not obvious, this patch is derived from copying and modifying
the similar hyperv feature support. Hopefully I've found all the
right pieces.
docs/formatdomain.html.in | 21 ++++
docs/schemas/domaincommon.rng | 18 +++-
src/conf/domain_conf.c | 100 ++++++++++++++++++++
src/conf/domain_conf.h | 9 ++
src/qemu/qemu_command.c | 22 ++++
tests/qemuargv2xmltest.c | 2
.../qemuxml2argv-kvm-features-off.args | 5 +
.../qemuxml2argv-kvm-features-off.xml | 27 +++++
.../qemuxml2argv-kvm-features.args | 5 +
.../qemuxml2argvdata/qemuxml2argv-kvm-features.xml | 27 +++++
tests/qemuxml2argvtest.c | 3 +
tests/qemuxml2xmltest.c | 3 +
12 files changed, 240 insertions(+), 2 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-kvm-features-off.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-kvm-features-off.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-kvm-features.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-kvm-features.xml
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index bd99ae0..32cc381 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -1232,6 +1232,9 @@
<vapic state='on'/>
<spinlocks state='on' retries='4096'/>
</hyperv>
+ <kvm>
+ <hidden state='on'/>
+ </kvm>
<pvspinlock/>
</features>
@@ -1310,7 +1313,23 @@
can be explicitly disabled by using <code>state='off'</code>
attribute.
</dd>
-
+ <dt><code>kvm</code></dt>
+ <dd>Various features to change the behavior of the KVM hypervisor.
+ <table class="top_table">
+ <tr>
+ <th>Feature</th>
+ <th>Description</th>
+ <th>Value</th>
+ <th>Since</th>
+ </tr>
+ <tr>
+ <td>hidden</td>
+ <td>Hide the KVM hypervisor from standard MSR based discovery</td>
+ <td> on, off</td>
+ <td><span class="since">2.1.0 (QEMU only)</span></td>
+ </tr>
+ </table>
+ </dd>
</dl>
<h3><a name="elementsTime">Time keeping</a></h3>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 033f2f6..5c99a14 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -3826,7 +3826,7 @@
</define>
<!--
A set of optional features: PAE, APIC, ACPI,
- HyperV Enlightenment, paravirtual spinlocks and HAP support
+ HyperV Enlightenment, KVM features, paravirtual spinlocks and HAP support
-->
<define name="features">
<optional>
@@ -3868,6 +3868,9 @@
</element>
</optional>
<optional>
+ <ref name="kvm"/>
+ </optional>
+ <optional>
<element name="privnet">
<empty/>
</element>
@@ -4472,6 +4475,19 @@
</element>
</define>
+ <!-- Optional KVM features -->
+ <define name="kvm">
+ <element name="kvm">
+ <interleave>
+ <optional>
+ <element name="hidden">
+ <ref name="featurestate"/>
+ </element>
+ </optional>
+ </interleave>
+ </element>
+ </define>
+
<!-- Optional capabilities features -->
<define name="capabilities">
<element name="capabilities">
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 934f6cb..8b0bdb0 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -142,6 +142,7 @@ VIR_ENUM_IMPL(virDomainFeature, VIR_DOMAIN_FEATURE_LAST,
"viridian",
"privnet",
"hyperv",
+ "kvm",
"pvspinlock",
"capabilities")
@@ -155,6 +156,9 @@ VIR_ENUM_IMPL(virDomainHyperv, VIR_DOMAIN_HYPERV_LAST,
"vapic",
"spinlocks")
+VIR_ENUM_IMPL(virDomainKVM, VIR_DOMAIN_KVM_LAST,
+ "hidden")
+
VIR_ENUM_IMPL(virDomainCapsFeature, VIR_DOMAIN_CAPS_FEATURE_LAST,
"audit_control",
"audit_write",
@@ -12168,6 +12172,7 @@ virDomainDefParseXML(xmlDocPtr xml,
case VIR_DOMAIN_FEATURE_VIRIDIAN:
case VIR_DOMAIN_FEATURE_PRIVNET:
case VIR_DOMAIN_FEATURE_HYPERV:
+ case VIR_DOMAIN_FEATURE_KVM:
def->features[val] = VIR_TRISTATE_SWITCH_ON;
break;
@@ -12295,6 +12300,54 @@ virDomainDefParseXML(xmlDocPtr xml,
ctxt->node = node;
}
+ if (def->features[VIR_DOMAIN_FEATURE_KVM] == VIR_TRISTATE_SWITCH_ON) {
+ int feature;
+ int value;
+ node = ctxt->node;
+ if ((n = virXPathNodeSet("./features/kvm/*", ctxt, &nodes)) < 0)
+ goto error;
+
+ for (i = 0; i < n; i++) {
+ feature = virDomainKVMTypeFromString((const char *)nodes[i]->name);
+ if (feature < 0) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("unsupported KVM feature: %s"),
+ nodes[i]->name);
+ goto error;
+ }
+
+ ctxt->node = nodes[i];
+
+ switch ((virDomainKVM) feature) {
+ case VIR_DOMAIN_KVM_HIDDEN:
+ if (!(tmp = virXPathString("string(./@state)", ctxt))) {
+ virReportError(VIR_ERR_XML_ERROR,
+ _("missing 'state' attribute for "
+ "KVM feature '%s'"),
+ nodes[i]->name);
+ goto error;
+ }
+
+ if ((value = virTristateSwitchTypeFromString(tmp)) < 0) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("invalid value of state argument "
+ "for KVM feature '%s'"),
+ nodes[i]->name);
+ goto error;
+ }
+
+ VIR_FREE(tmp);
+ def->kvm_features[feature] = value;
+ break;
+
+ case VIR_DOMAIN_KVM_LAST:
+ break;
+ }
+ }
+ VIR_FREE(nodes);
+ ctxt->node = node;
+ }
+
if ((n = virXPathNodeSet("./features/capabilities/*", ctxt, &nodes)) < 0)
goto error;
@@ -14303,6 +14356,29 @@ virDomainDefFeaturesCheckABIStability(virDomainDefPtr src,
}
}
+ /* kvm */
+ if (src->features[VIR_DOMAIN_FEATURE_KVM] == VIR_TRISTATE_SWITCH_ON) {
+ for (i = 0; i < VIR_DOMAIN_KVM_LAST; i++) {
+ switch ((virDomainKVM) i) {
+ case VIR_DOMAIN_KVM_HIDDEN:
+ if (src->kvm_features[i] != dst->kvm_features[i]) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("State of KVM feature '%s' differs: "
+ "source: '%s', destination: '%s'"),
+ virDomainKVMTypeToString(i),
+ virTristateSwitchTypeToString(src->kvm_features[i]),
+ virTristateSwitchTypeToString(dst->kvm_features[i]));
+ return false;
+ }
+
+ break;
+
+ case VIR_DOMAIN_KVM_LAST:
+ break;
+ }
+ }
+ }
+
return true;
}
@@ -18133,6 +18209,30 @@ virDomainDefFormatInternal(virDomainDefPtr def,
virBufferAddLit(buf, "</hyperv>\n");
break;
+ case VIR_DOMAIN_FEATURE_KVM:
+ if (def->features[i] != VIR_TRISTATE_SWITCH_ON)
+ break;
+
+ virBufferAddLit(buf, "<kvm>\n");
+ virBufferAdjustIndent(buf, 2);
+ for (j = 0; j < VIR_DOMAIN_KVM_LAST; j++) {
+ switch ((virDomainKVM) j) {
+ case VIR_DOMAIN_KVM_HIDDEN:
+ if (def->kvm_features[j])
+ virBufferAsprintf(buf, "<%s state='%s'/>\n",
+ virDomainKVMTypeToString(j),
+ virTristateSwitchTypeToString(
+ def->kvm_features[j]));
+ break;
+
+ case VIR_DOMAIN_KVM_LAST:
+ break;
+ }
+ }
+ virBufferAdjustIndent(buf, -2);
+ virBufferAddLit(buf, "</kvm>\n");
+ break;
+
case VIR_DOMAIN_FEATURE_CAPABILITIES:
if (def->features[i] == VIR_DOMAIN_CAPABILITIES_POLICY_DEFAULT &&
!virDomainDefHasCapabilitiesFeatures(def))
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index ff7d640..cca9c0f 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1515,6 +1515,7 @@ typedef enum {
VIR_DOMAIN_FEATURE_VIRIDIAN,
VIR_DOMAIN_FEATURE_PRIVNET,
VIR_DOMAIN_FEATURE_HYPERV,
+ VIR_DOMAIN_FEATURE_KVM,
VIR_DOMAIN_FEATURE_PVSPINLOCK,
VIR_DOMAIN_FEATURE_CAPABILITIES,
@@ -1530,6 +1531,12 @@ typedef enum {
} virDomainHyperv;
typedef enum {
+ VIR_DOMAIN_KVM_HIDDEN = 0,
+
+ VIR_DOMAIN_KVM_LAST
+} virDomainKVM;
+
+typedef enum {
VIR_DOMAIN_CAPABILITIES_POLICY_DEFAULT = 0,
VIR_DOMAIN_CAPABILITIES_POLICY_ALLOW,
VIR_DOMAIN_CAPABILITIES_POLICY_DENY,
@@ -1943,6 +1950,7 @@ struct _virDomainDef {
int features[VIR_DOMAIN_FEATURE_LAST];
int apic_eoi;
int hyperv_features[VIR_DOMAIN_HYPERV_LAST];
+ int kvm_features[VIR_DOMAIN_KVM_LAST];
unsigned int hyperv_spinlocks;
/* These options are of type virTristateSwitch: ON = keep, OFF = drop */
@@ -2626,6 +2634,7 @@ VIR_ENUM_DECL(virDomainGraphicsSpiceStreamingMode)
VIR_ENUM_DECL(virDomainGraphicsSpiceMouseMode)
VIR_ENUM_DECL(virDomainGraphicsVNCSharePolicy)
VIR_ENUM_DECL(virDomainHyperv)
+VIR_ENUM_DECL(virDomainKVM)
VIR_ENUM_DECL(virDomainRNGModel)
VIR_ENUM_DECL(virDomainRNGBackend)
VIR_ENUM_DECL(virDomainTPMModel)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 8a69976..77a84cc 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -6228,6 +6228,25 @@ qemuBuildCpuArgStr(virQEMUDriverPtr driver,
}
}
+ if (def->features[VIR_DOMAIN_FEATURE_KVM] == VIR_TRISTATE_SWITCH_ON) {
+ if (!have_cpu) {
+ virBufferAdd(&buf, default_model, -1);
+ have_cpu = true;
+ }
+
+ for (i = 0; i < VIR_DOMAIN_KVM_LAST; i++) {
+ switch ((virDomainKVM) i) {
+ case VIR_DOMAIN_KVM_HIDDEN:
+ if (def->kvm_features[i] == VIR_TRISTATE_SWITCH_ON)
+ virBufferAsprintf(&buf, ",kvm=off");
+ break;
+
+ case VIR_DOMAIN_KVM_LAST:
+ break;
+ }
+ }
+ }
+
if (virBufferCheckError(&buf) < 0)
goto cleanup;
@@ -10692,6 +10711,9 @@ qemuParseCommandLineCPU(virDomainDefPtr dom,
}
virStringFreeList(hv_tokens);
hv_tokens = NULL;
+ } else if (STREQ(tokens[i], "kvm=off")) {
+ dom->features[VIR_DOMAIN_FEATURE_KVM] = VIR_TRISTATE_SWITCH_ON;
+ dom->kvm_features[VIR_DOMAIN_KVM_HIDDEN] = VIR_TRISTATE_SWITCH_ON;
}
}
diff --git a/tests/qemuargv2xmltest.c b/tests/qemuargv2xmltest.c
index 6bad7d6..9c00cd9 100644
--- a/tests/qemuargv2xmltest.c
+++ b/tests/qemuargv2xmltest.c
@@ -284,6 +284,8 @@ mymain(void)
DO_TEST("hyperv");
+ DO_TEST("kvm-features");
+
DO_TEST("pseries-nvram");
DO_TEST("pseries-disk");
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-kvm-features-off.args b/tests/qemuxml2argvdata/qemuxml2argv-kvm-features-off.args
new file mode 100644
index 0000000..363fd2a
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-kvm-features-off.args
@@ -0,0 +1,5 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
+/usr/bin/qemu \
+-S -M pc -cpu qemu32 -m 214 -smp 6 -nographic \
+-monitor unix:/tmp/test-monitor,server,nowait \
+-boot n -usb -net none -serial none -parallel none
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-kvm-features-off.xml b/tests/qemuxml2argvdata/qemuxml2argv-kvm-features-off.xml
new file mode 100644
index 0000000..64b8cd8
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-kvm-features-off.xml
@@ -0,0 +1,27 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219100</memory>
+ <currentMemory unit='KiB'>219100</currentMemory>
+ <vcpu placement='static'>6</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='network'/>
+ </os>
+ <features>
+ <acpi/>
+ <kvm>
+ <hidden state='off'/>
+ </kvm>
+ </features>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu</emulator>
+ <controller type='usb' index='0'/>
+ <controller type='pci' index='0' model='pci-root'/>
+ <memballoon model='virtio'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-kvm-features.args b/tests/qemuxml2argvdata/qemuxml2argv-kvm-features.args
new file mode 100644
index 0000000..b223951
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-kvm-features.args
@@ -0,0 +1,5 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
+/usr/bin/qemu -S -M pc \
+-cpu qemu32,kvm=off -m 214 -smp 6 -nographic -monitor \
+unix:/tmp/test-monitor,server,nowait -boot n -usb -net none -serial none \
+-parallel none
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-kvm-features.xml b/tests/qemuxml2argvdata/qemuxml2argv-kvm-features.xml
new file mode 100644
index 0000000..3f2817e
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-kvm-features.xml
@@ -0,0 +1,27 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219100</memory>
+ <currentMemory unit='KiB'>219100</currentMemory>
+ <vcpu placement='static'>6</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='network'/>
+ </os>
+ <features>
+ <acpi/>
+ <kvm>
+ <hidden state='on'/>
+ </kvm>
+ </features>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu</emulator>
+ <controller type='usb' index='0'/>
+ <controller type='pci' index='0' model='pci-root'/>
+ <memballoon model='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 62b969c..427ebfc 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -666,6 +666,9 @@ mymain(void)
DO_TEST("hyperv", NONE);
DO_TEST("hyperv-off", NONE);
+ DO_TEST("kvm-features", NONE);
+ DO_TEST("kvm-features-off", NONE);
+
DO_TEST("hugepages", QEMU_CAPS_MEM_PATH);
DO_TEST("hugepages-pages", QEMU_CAPS_MEM_PATH, QEMU_CAPS_OBJECT_MEMORY_RAM,
QEMU_CAPS_OBJECT_MEMORY_FILE);
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 5941323..3a174c0 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -196,6 +196,9 @@ mymain(void)
DO_TEST("hyperv");
DO_TEST("hyperv-off");
+ DO_TEST("kvm-features");
+ DO_TEST("kvm-features-off");
+
DO_TEST("hugepages");
DO_TEST("hugepages-pages");
DO_TEST("hugepages-pages2");
10 years, 3 months
Re: [libvirt] [PATCH] numatune: setting --mode does not work well
by Erik Skultety
I see your point, yes, you are right, a leak might occur and I'll fix it
in the cleanup phase. Just to be correct, it is not related to the
error-check you pointed out. It is because up until now, numatune was
only a local duplicate pointer to an allocated memory which was
referenced by *numatunePtr (passed as argument). And this was the core
of the bug, working directly with a pointer passed to the function. If
any problem occures, that pointer should stay untouched, that's why I
slightly changed the allocation, thus unfortunately creating a
possibility for the leak. So I'm putting another 'if(create)' clause
inside the cleanup phase in PATCHv2.
Regards,
Erik
On 08/20/2014 02:50 PM, Ján Tomko wrote:
> On 08/20/2014 12:49 PM, Erik Skultety wrote:
>> When trying to set numatune mode directly using virsh numatune command,
>> correct error is raised, however numatune structure was not deallocated,
>> thus resulting in creating an empty numatune element in the guest XML,
>> if none was present before. Running the same command aftewards results
>> in a successful change with broken XML structure. Patch fixes the
>> deallocation problem as well as checking for invalid attribute
>> combination VIR_DOMAIN_NUMATUNE_PLACEMENT_AUTO + a nonempty nodeset.
>>
>> Resolves https://bugzilla.redhat.com/show_bug.cgi?id=1129998
>> ---
>> src/conf/numatune_conf.c | 28 +++++++++++++++++++---------
>> 1 file changed, 19 insertions(+), 9 deletions(-)
>>
>> diff --git a/src/conf/numatune_conf.c b/src/conf/numatune_conf.c
>> index 48d1d04..45bf0cb 100644
>> --- a/src/conf/numatune_conf.c
>> +++ b/src/conf/numatune_conf.c
>> @@ -439,7 +439,7 @@ virDomainNumatuneSet(virDomainNumatunePtr *numatunePtr,
>> {
>> bool create = !*numatunePtr; /* Whether we are creating new struct */
>> int ret = -1;
>> - virDomainNumatunePtr numatune = NULL;
>> + virDomainNumatunePtr numatune = *numatunePtr;
>>
>> /* No need to do anything in this case */
>> if (mode == -1 && placement == -1 && !nodeset)
>> @@ -461,9 +461,15 @@ virDomainNumatuneSet(virDomainNumatunePtr *numatunePtr,
>> goto cleanup;
>> }
>>
>> - if (create && VIR_ALLOC(*numatunePtr) < 0)
>> + if (placement_static && !nodeset) {
>> + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
>> + _("nodeset for NUMA memory tuning must be set "
>> + "if 'placement' is 'static'"));
>> + goto cleanup;
>
> You moved this error above the allocation, but there is another 'goto cleanup'
> possible after the successful allocation of 'numatune':
>
> if (nodeset) {
> virBitmapFree(numatune->memory.nodeset);
> numatune->memory.nodeset = virBitmapNewCopy(nodeset);
> if (!numatune->memory.nodeset)
> goto cleanup;
> if (placement == -1)
> placement = VIR_DOMAIN_NUMATUNE_PLACEMENT_STATIC;
> }
>
> If virBitmapNewCopy fails and numatune was allocated by this function, it's
> leaked.
>
> Jan
>
>
>
> --
> libvir-list mailing list
> libvir-list(a)redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list
>
10 years, 3 months
[libvirt] [PATCH] examples: test: Kill unsupported maxMemory element
by Peter Krempa
The "maxMemory" element was never supported by libvirt. Remove it from
the test XMLs. (Found while actually trying to add support for a
identically named element).
---
examples/xml/test/testdomfv0.xml | 1 -
examples/xml/test/testnodeinline.xml | 1 -
2 files changed, 2 deletions(-)
diff --git a/examples/xml/test/testdomfv0.xml b/examples/xml/test/testdomfv0.xml
index 157c8ec..fc209cc 100644
--- a/examples/xml/test/testdomfv0.xml
+++ b/examples/xml/test/testdomfv0.xml
@@ -7,7 +7,6 @@
<boot dev='hd'/>
</os>
<memory>524288</memory>
- <maxMemory>1524288</maxMemory>
<vcpu>4</vcpu>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
diff --git a/examples/xml/test/testnodeinline.xml b/examples/xml/test/testnodeinline.xml
index b353f39..0ec0f1a 100644
--- a/examples/xml/test/testnodeinline.xml
+++ b/examples/xml/test/testnodeinline.xml
@@ -17,7 +17,6 @@
<boot dev="hd"/>
</os>
<memory>524288</memory>
- <maxMemory>1524288</maxMemory>
<vcpu>4</vcpu>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
--
2.0.2
10 years, 3 months
[libvirt] [libvirt-glib] [PATCH v2 1/4] GVirDomain: Fix some doc comments of the snapshot API
by Timm Bäder
Fixes the following warnings from g-ir-scanner and some cosmetic issues:
libvirt-gobject-domain.c:1532: Warning: LibvirtGObject: unknown
annotation: transfer-none
libvirt-gobject-domain.c:1650: Error: LibvirtGObject: identifier not
found on the first line:
*
^
---
libvirt-gobject/libvirt-gobject-domain.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/libvirt-gobject/libvirt-gobject-domain.c b/libvirt-gobject/libvirt-gobject-domain.c
index feac6f0..aa2a170 100644
--- a/libvirt-gobject/libvirt-gobject-domain.c
+++ b/libvirt-gobject/libvirt-gobject-domain.c
@@ -1529,10 +1529,10 @@ gvir_domain_create_snapshot(GVirDomain *dom,
* gvir_domain_fetch_snapshots:
* @dom: The domain
* @list_flags: bitwise-OR of #GVirDomainSnapshotListFlags
- * @cancellable: (allow-none)(transfer-none): cancellation object
- * @error: (allow-none): Place-holder for error or NULL
+ * @cancellable: (allow-none) (transfer none): cancellation object
+ * @error: (allow-none): Place-holder for error or %NULL
*
- * Returns: TRUE on success, FALSE otherwise.
+ * Returns: %TRUE on success, %FALSE otherwise.
*/
gboolean gvir_domain_fetch_snapshots(GVirDomain *dom,
guint list_flags,
@@ -1647,10 +1647,10 @@ static void _fetch_snapshots_async_thread(GTask *task,
/**
- *
+ * gvir_domain_fetch_snapshots_async:
* @dom: The domain
* @list_flags: bitwise-OR of #GVirDomainSnapshotListFlags
- * @cancellable: (allow-none)(transfer-none): cancellation object
+ * @cancellable: (allow-none) (transfer none): cancellation object
* @callback: (scope async): completion callback
* @user_data: (closure): opaque data for callback
*/
--
2.0.4
10 years, 3 months
[libvirt] [PATCH] numatune: setting --mode does not work well
by Erik Skultety
When trying to set numatune mode directly using virsh numatune command,
correct error is raised, however numatune structure was not deallocated,
thus resulting in creating an empty numatune element in the guest XML,
if none was present before. Running the same command aftewards results
in a successful change with broken XML structure. Patch fixes the
deallocation problem as well as checking for invalid attribute
combination VIR_DOMAIN_NUMATUNE_PLACEMENT_AUTO + a nonempty nodeset.
Resolves https://bugzilla.redhat.com/show_bug.cgi?id=1129998
---
src/conf/numatune_conf.c | 28 +++++++++++++++++++---------
1 file changed, 19 insertions(+), 9 deletions(-)
diff --git a/src/conf/numatune_conf.c b/src/conf/numatune_conf.c
index 48d1d04..45bf0cb 100644
--- a/src/conf/numatune_conf.c
+++ b/src/conf/numatune_conf.c
@@ -439,7 +439,7 @@ virDomainNumatuneSet(virDomainNumatunePtr *numatunePtr,
{
bool create = !*numatunePtr; /* Whether we are creating new struct */
int ret = -1;
- virDomainNumatunePtr numatune = NULL;
+ virDomainNumatunePtr numatune = *numatunePtr;
/* No need to do anything in this case */
if (mode == -1 && placement == -1 && !nodeset)
@@ -461,9 +461,15 @@ virDomainNumatuneSet(virDomainNumatunePtr *numatunePtr,
goto cleanup;
}
- if (create && VIR_ALLOC(*numatunePtr) < 0)
+ if (placement_static && !nodeset) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("nodeset for NUMA memory tuning must be set "
+ "if 'placement' is 'static'"));
+ goto cleanup;
+ }
+
+ if (create && VIR_ALLOC(numatune) < 0)
goto cleanup;
- numatune = *numatunePtr;
if (create) {
/* Defaults for new struct */
@@ -492,12 +498,11 @@ virDomainNumatuneSet(virDomainNumatunePtr *numatunePtr,
placement = VIR_DOMAIN_NUMATUNE_PLACEMENT_AUTO;
}
- if (placement == VIR_DOMAIN_NUMATUNE_PLACEMENT_STATIC &&
- !numatune->memory.nodeset) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("nodeset for NUMA memory tuning must be set "
- "if 'placement' is 'static'"));
- goto cleanup;
+ /* setting nodeset when placement auto is invalid */
+ if (placement == VIR_DOMAIN_NUMATUNE_PLACEMENT_AUTO &&
+ numatune->memory.nodeset) {
+ virBitmapFree(numatune->memory.nodeset);
+ numatune->memory.nodeset = NULL;
}
if (placement != -1)
@@ -505,6 +510,11 @@ virDomainNumatuneSet(virDomainNumatunePtr *numatunePtr,
numatune->memory.specified = true;
+ if (create) {
+ *numatunePtr = numatune;
+ numatune = NULL;
+ }
+
ret = 0;
cleanup:
return ret;
--
1.9.3
10 years, 3 months
[libvirt] [PATCH 00/20] vbox: Rewrite StorageDriver
by Taowei
The last part of rewriting vbox driver.
This series of patch is based on the patches rewriting network driver:
https://www.redhat.com/archives/libvir-list/2014-August/msg00842.html
Taowei (20):
vbox: Rewrite vboxStorageOpen
vbox: Rewrite vboxStorageClose
vbox: Rewrite vboxConnectNumOfStoragePools
vbox: Rewrite vboxConnectListStoragePools
vbox: Rewrite vboxStoragePoolLookupByName
vbox: Rewrite vboxStoragePoolNumOfVolumes
vbox: Rewrite vboxStoragePoolListVolumes
vbox: Rewrite vboxStorageVolLookupByName
vbox: Rewrite vboxStorageVolLookupByKey
vbox: Make FindMedium support old vbox versions
vbox: Rewrite vboxStorageVolLookupByPath
vbox: Make CreateHardDisk support all vbox versions
vbox: Rewrite vboxStorageVolCreateXML
vbox: Make IMediumAttachment work with vbox2.2 and 3.0
vbox: Rewrite vboxStorageVolDelete
vbox: Rewrite vboxStorageVolGetInfo
vbox: Rewrite vboxStorageVolGetXMLDesc
vbox: Rewrite vboxStorageVolGetPath
vbox: Introducing vboxCommonStorageDriver
vbox: Remove unused things in vbox_tmpl.c
src/vbox/vbox_common.c | 858 ++++++++++++++++++++++++++++++-
src/vbox/vbox_common.h | 22 +
src/vbox/vbox_driver.c | 52 +-
src/vbox/vbox_tmpl.c | 1142 +++++------------------------------------
src/vbox/vbox_uniformed_api.h | 28 +-
5 files changed, 1039 insertions(+), 1063 deletions(-)
--
1.7.9.5
10 years, 3 months
[libvirt] [PATCH v3 libvirt 0/3] Add support for qemu usb-mtp device
by Giuseppe Scrivano
This series adds support for qemu usb-mtp devices.
This new version addresses comments for v2:
https://www.redhat.com/archives/libvir-list/2014-August/msg00471.html
Giuseppe Scrivano (3):
conf: add <model> child element to <filesystem>
docs: relax <filesystem>/<target> dir element attribute to string
qemu: add support for MTP filesystem
docs/formatdomain.html.in | 6 +++
docs/schemas/domaincommon.rng | 17 +++++--
src/conf/domain_conf.c | 26 +++++++++++
src/conf/domain_conf.h | 11 +++++
src/qemu/qemu_command.c | 65 ++++++++++++++++----------
tests/domainconfdata/getfilesystem.xml | 5 ++
tests/domainconftest.c | 1 +
tests/qemuxml2argvdata/qemuxml2argv-fsmtp.args | 6 +++
tests/qemuxml2argvdata/qemuxml2argv-fsmtp.xml | 30 ++++++++++++
9 files changed, 140 insertions(+), 27 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-fsmtp.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-fsmtp.xml
--
1.9.3
10 years, 3 months
[libvirt] [PATCH] cleanup spaces between parentheses and curly brackets
by Martin Kletzander
And add a syntax-check for '){$'. It's not perfect, but better than
nothing.
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
cfg.mk | 6 ++++++
docs/java.html.in | 4 ++--
src/conf/domain_conf.c | 2 +-
src/conf/node_device_conf.c | 2 +-
src/conf/nwfilter_params.c | 2 +-
src/conf/storage_conf.c | 2 +-
src/libvirt.c | 8 ++++----
src/lxc/lxc_driver.c | 4 ++--
src/qemu/qemu_driver.c | 2 +-
src/qemu/qemu_monitor_json.c | 2 +-
src/rpc/virnettlscontext.c | 2 +-
src/security/virt-aa-helper.c | 2 +-
src/util/virdnsmasq.c | 2 +-
src/util/virstorageencryption.c | 2 +-
src/xen/xen_driver.c | 2 +-
src/xen/xen_hypervisor.c | 22 +++++++++++-----------
src/xen/xend_internal.c | 6 +++---
tests/libvirtdconftest.c | 2 +-
tools/virsh-volume.c | 2 +-
19 files changed, 41 insertions(+), 35 deletions(-)
diff --git a/cfg.mk b/cfg.mk
index 4e302c8..825e5ce 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -943,6 +943,12 @@ sc_prohibit_empty_first_line:
print "$(ME): Prohibited empty first line" > "/dev/stderr"; \
} exit fail; }' $$($(VC_LIST_EXCEPT));
+sc_prohibit_parentheses_conjuncted_with_curly_bracket:
+ @prohibit='\)\{$$' \
+ in_vc_files='\.[ch]$$' \
+ halt='put space between parentheses and curly bracket' \
+ $(_sc_search_regexp)
+
# We don't use this feature of maint.mk.
prev_version_file = /dev/null
diff --git a/docs/java.html.in b/docs/java.html.in
index b5812ba..daa7b76 100644
--- a/docs/java.html.in
+++ b/docs/java.html.in
@@ -130,7 +130,7 @@ public class minitest {
Connect conn=null;
try{
conn = new <span style="color: #0071FF; background-color: #FFFFFF">Connect</span>("test:///default", true);
- } catch (<span style="color: #0071FF; background-color: #FFFFFF">LibvirtException</span> e){
+ } catch (<span style="color: #0071FF; background-color: #FFFFFF">LibvirtException</span> e) {
System.out.println("exception caught:"+e);
System.out.println(e.getError());
}
@@ -139,7 +139,7 @@ public class minitest {
System.out.println("Domain:" + testDomain.<span style="color: #E50073; background-color: #FFFFFF">getName</span>() + " id " +
testDomain.<span style="color: #E50073; background-color: #FFFFFF">getID</span>() + " running " +
testDomain.<span style="color: #E50073; background-color: #FFFFFF">getOSType</span>());
- } catch (<span style="color: #0071FF; background-color: #FFFFFF">LibvirtException</span> e){
+ } catch (<span style="color: #0071FF; background-color: #FFFFFF">LibvirtException</span> e) {
System.out.println("exception caught:"+e);
System.out.println(e.getError());
}
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index d14191f..9557020 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -14423,7 +14423,7 @@ virDomainDefCheckABIStability(virDomainDefPtr src,
dst->os.type, src->os.type);
goto error;
}
- if (src->os.arch != dst->os.arch){
+ if (src->os.arch != dst->os.arch) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Target domain architecture %s does not match source %s"),
virArchToString(dst->os.arch),
diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c
index 025d08c..54290ae 100644
--- a/src/conf/node_device_conf.c
+++ b/src/conf/node_device_conf.c
@@ -187,7 +187,7 @@ virNodeDeviceObjPtr virNodeDeviceAssignDef(virNodeDeviceObjListPtr devs,
}
virNodeDeviceObjLock(device);
- if (VIR_APPEND_ELEMENT_COPY(devs->objs, devs->count, device) < 0){
+ if (VIR_APPEND_ELEMENT_COPY(devs->objs, devs->count, device) < 0) {
virNodeDeviceObjUnlock(device);
virNodeDeviceObjFree(device);
return NULL;
diff --git a/src/conf/nwfilter_params.c b/src/conf/nwfilter_params.c
index a12e645..e561943 100644
--- a/src/conf/nwfilter_params.c
+++ b/src/conf/nwfilter_params.c
@@ -724,7 +724,7 @@ addToTable(void *payload, const void *name, void *data)
return;
}
- if (virNWFilterHashTablePut(atts->target, (const char *)name, val) < 0){
+ if (virNWFilterHashTablePut(atts->target, (const char *)name, val) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Could not put variable '%s' into hashmap"),
(const char *)name);
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index b61d8c0..5a16767 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -2122,7 +2122,7 @@ virStoragePoolSourceFindDuplicate(virStoragePoolObjListPtr pools,
def->source.adapter.data.fchost.wwpn))
matchpool = pool;
} else if (pool->def->source.adapter.type ==
- VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST){
+ VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST) {
if (pool->def->source.adapter.data.scsi_host.name) {
if (STREQ(pool->def->source.adapter.data.scsi_host.name,
def->source.adapter.data.scsi_host.name))
diff --git a/src/libvirt.c b/src/libvirt.c
index 992e4f2..8349261 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -7613,7 +7613,7 @@ virDomainGetSchedulerType(virDomainPtr domain, int *nparams)
virCheckDomainReturn(domain, NULL);
conn = domain->conn;
- if (conn->driver->domainGetSchedulerType){
+ if (conn->driver->domainGetSchedulerType) {
schedtype = conn->driver->domainGetSchedulerType(domain, nparams);
if (!schedtype)
goto error;
@@ -10987,7 +10987,7 @@ virNetworkLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
virCheckConnectReturn(conn, NULL);
virCheckNonNullArgGoto(uuid, error);
- if (conn->networkDriver && conn->networkDriver->networkLookupByUUID){
+ if (conn->networkDriver && conn->networkDriver->networkLookupByUUID) {
virNetworkPtr ret;
ret = conn->networkDriver->networkLookupByUUID(conn, uuid);
if (!ret)
@@ -14217,7 +14217,7 @@ virStorageVolGetInfo(virStorageVolPtr vol,
conn = vol->conn;
- if (conn->storageDriver->storageVolGetInfo){
+ if (conn->storageDriver->storageVolGetInfo) {
int ret;
ret = conn->storageDriver->storageVolGetInfo(vol, info);
if (ret < 0)
@@ -16964,7 +16964,7 @@ virNWFilterLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
virCheckConnectReturn(conn, NULL);
virCheckNonNullArgGoto(uuid, error);
- if (conn->nwfilterDriver && conn->nwfilterDriver->nwfilterLookupByUUID){
+ if (conn->nwfilterDriver && conn->nwfilterDriver->nwfilterLookupByUUID) {
virNWFilterPtr ret;
ret = conn->nwfilterDriver->nwfilterLookupByUUID(conn, uuid);
if (!ret)
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index d65dda0..66d708a 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -2193,7 +2193,7 @@ lxcDomainParseBlkioDeviceStr(char *blkioDeviceStr, const char *type,
} else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_READ_BPS)) {
if (virStrToLong_ullp(temp, &p, 10, &result[i].rbps) < 0)
goto error;
- } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WRITE_BPS)){
+ } else if (STREQ(type, VIR_DOMAIN_BLKIO_DEVICE_WRITE_BPS)) {
if (virStrToLong_ullp(temp, &p, 10, &result[i].wbps) < 0)
goto error;
} else {
@@ -2606,7 +2606,7 @@ lxcDomainSetBlkioParameters(virDomainPtr dom,
break;
}
}
- } else if (STREQ(param->field, VIR_DOMAIN_BLKIO_DEVICE_WRITE_BPS)){
+ } else if (STREQ(param->field, VIR_DOMAIN_BLKIO_DEVICE_WRITE_BPS)) {
for (j = 0; j < ndevices; j++) {
if (virCgroupSetBlkioDeviceWriteBps(priv->cgroup,
devices[j].path,
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 28a56a9..2c56692 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -7865,7 +7865,7 @@ qemuDomainSetBlkioParameters(virDomainPtr dom,
break;
}
}
- } else if (STREQ(param->field, VIR_DOMAIN_BLKIO_DEVICE_WRITE_BPS)){
+ } else if (STREQ(param->field, VIR_DOMAIN_BLKIO_DEVICE_WRITE_BPS)) {
for (j = 0; j < ndevices; j++) {
if (virCgroupSetBlkioDeviceWriteBps(priv->cgroup,
devices[j].path,
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index a62c02f..3972960 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -3868,7 +3868,7 @@ qemuMonitorJSONBlockJob(qemuMonitorPtr mon,
virReportError(VIR_ERR_OPERATION_INVALID,
_("No active operation on device: %s"),
device);
- } else if (qemuMonitorJSONHasError(reply, "DeviceInUse")){
+ } else if (qemuMonitorJSONHasError(reply, "DeviceInUse")) {
virReportError(VIR_ERR_OPERATION_FAILED,
_("Device %s in use"), device);
} else if (qemuMonitorJSONHasError(reply, "NotSupported")) {
diff --git a/src/rpc/virnettlscontext.c b/src/rpc/virnettlscontext.c
index 032ff64..31aac9d 100644
--- a/src/rpc/virnettlscontext.c
+++ b/src/rpc/virnettlscontext.c
@@ -1003,7 +1003,7 @@ static int virNetTLSContextValidCertificate(virNetTLSContextPtr ctxt,
memset(dname, 0, dnamesize);
- if ((ret = gnutls_certificate_verify_peers2(sess->session, &status)) < 0){
+ if ((ret = gnutls_certificate_verify_peers2(sess->session, &status)) < 0) {
virReportError(VIR_ERR_SYSTEM_ERROR,
_("Unable to verify TLS peer: %s"),
gnutls_strerror(ret));
diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c
index f25a7df7..a0b104c 100644
--- a/src/security/virt-aa-helper.c
+++ b/src/security/virt-aa-helper.c
@@ -1075,7 +1075,7 @@ get_files(vahControl * ctl)
ctl->def->fss[i]->type == VIR_DOMAIN_FS_TYPE_MOUNT &&
(ctl->def->fss[i]->fsdriver == VIR_DOMAIN_FS_DRIVER_TYPE_PATH ||
ctl->def->fss[i]->fsdriver == VIR_DOMAIN_FS_DRIVER_TYPE_DEFAULT) &&
- ctl->def->fss[i]->src){
+ ctl->def->fss[i]->src) {
virDomainFSDefPtr fs = ctl->def->fss[i];
if (vah_add_path(&buf, fs->src, fs->readonly ? "r" : "rw", true) != 0)
diff --git a/src/util/virdnsmasq.c b/src/util/virdnsmasq.c
index 5991fe7..d2c4aa9 100644
--- a/src/util/virdnsmasq.c
+++ b/src/util/virdnsmasq.c
@@ -332,7 +332,7 @@ hostsfileAdd(dnsmasqHostsfile *hostsfile,
if (virAsprintf(&hostsfile->hosts[hostsfile->nhosts].host, "%s,%s,%s",
mac, ipstr, name) < 0)
goto error;
- } else if (name && !mac){
+ } else if (name && !mac) {
if (virAsprintf(&hostsfile->hosts[hostsfile->nhosts].host, "%s,%s",
name, ipstr) < 0)
goto error;
diff --git a/src/util/virstorageencryption.c b/src/util/virstorageencryption.c
index 5a401b7..b5fed58 100644
--- a/src/util/virstorageencryption.c
+++ b/src/util/virstorageencryption.c
@@ -193,7 +193,7 @@ virStorageEncryptionParseXML(xmlXPathContextPtr ctxt)
ret->format = format;
n = virXPathNodeSet("./secret", ctxt, &nodes);
- if (n < 0){
+ if (n < 0) {
goto cleanup;
}
if (n != 0 && VIR_ALLOC_N(ret->secrets, n) < 0)
diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c
index 79df3ee..0fc3aca 100644
--- a/src/xen/xen_driver.c
+++ b/src/xen/xen_driver.c
@@ -2534,7 +2534,7 @@ xenUnifiedNodeDeviceAssignedDomainId(virNodeDevicePtr dev)
if (numdomains < 0) {
return ret;
}
- if (numdomains > 0){
+ if (numdomains > 0) {
if (VIR_ALLOC_N(ids, numdomains) < 0)
goto out;
if ((numdomains = xenUnifiedConnectListDomains(conn, &ids[0], numdomains)) < 0) {
diff --git a/src/xen/xen_hypervisor.c b/src/xen/xen_hypervisor.c
index 09aa1aa..0931234 100644
--- a/src/xen/xen_hypervisor.c
+++ b/src/xen/xen_hypervisor.c
@@ -1194,7 +1194,7 @@ xenHypervisorGetSchedulerType(virConnectPtr conn,
if (ret < 0)
return NULL;
- switch (op.u.getschedulerid.sched_id){
+ switch (op.u.getschedulerid.sched_id) {
case XEN_SCHEDULER_SEDF:
ignore_value(VIR_STRDUP(schedulertype, "sedf"));
if (nparams)
@@ -1257,7 +1257,7 @@ xenHypervisorGetSchedulerParameters(virConnectPtr conn,
if (ret < 0)
return -1;
- switch (op_sys.u.getschedulerid.sched_id){
+ switch (op_sys.u.getschedulerid.sched_id) {
case XEN_SCHEDULER_SEDF:
if (*nparams < XEN_SCHED_SEDF_NPARAM) {
virReportError(VIR_ERR_INVALID_ARG,
@@ -1360,7 +1360,7 @@ xenHypervisorSetSchedulerParameters(virConnectPtr conn,
ret = xenHypervisorDoV2Sys(priv->handle, &op_sys);
if (ret == -1) return -1;
- switch (op_sys.u.getschedulerid.sched_id){
+ switch (op_sys.u.getschedulerid.sched_id) {
case XEN_SCHEDULER_SEDF:
/* TODO: Implement for Xen/SEDF */
TODO
@@ -1885,13 +1885,13 @@ xenHypervisorInit(struct xenHypervisorVersions *override_versions)
if (virXen_getdomaininfo(fd, 0, &info) == 1) {
/* RHEL 5.0 */
hv_versions.dom_interface = 3; /* XEN_DOMCTL_INTERFACE_VERSION */
- if (virXen_getvcpusinfo(fd, 0, 0, ipt, NULL, 0) == 0){
+ if (virXen_getvcpusinfo(fd, 0, 0, ipt, NULL, 0) == 0) {
VIR_DEBUG("Using hypervisor call v2, sys ver2 dom ver3");
goto done;
}
/* Fedora 7 */
hv_versions.dom_interface = 4; /* XEN_DOMCTL_INTERFACE_VERSION */
- if (virXen_getvcpusinfo(fd, 0, 0, ipt, NULL, 0) == 0){
+ if (virXen_getvcpusinfo(fd, 0, 0, ipt, NULL, 0) == 0) {
VIR_DEBUG("Using hypervisor call v2, sys ver2 dom ver4");
goto done;
}
@@ -1901,7 +1901,7 @@ xenHypervisorInit(struct xenHypervisorVersions *override_versions)
if (virXen_getdomaininfo(fd, 0, &info) == 1) {
/* xen-3.1 */
hv_versions.dom_interface = 5; /* XEN_DOMCTL_INTERFACE_VERSION */
- if (virXen_getvcpusinfo(fd, 0, 0, ipt, NULL, 0) == 0){
+ if (virXen_getvcpusinfo(fd, 0, 0, ipt, NULL, 0) == 0) {
VIR_DEBUG("Using hypervisor call v2, sys ver3 dom ver5");
goto done;
}
@@ -1911,7 +1911,7 @@ xenHypervisorInit(struct xenHypervisorVersions *override_versions)
if (virXen_getdomaininfo(fd, 0, &info) == 1) {
/* Fedora 8 */
hv_versions.dom_interface = 5; /* XEN_DOMCTL_INTERFACE_VERSION */
- if (virXen_getvcpusinfo(fd, 0, 0, ipt, NULL, 0) == 0){
+ if (virXen_getvcpusinfo(fd, 0, 0, ipt, NULL, 0) == 0) {
VIR_DEBUG("Using hypervisor call v2, sys ver4 dom ver5");
goto done;
}
@@ -1921,7 +1921,7 @@ xenHypervisorInit(struct xenHypervisorVersions *override_versions)
if (virXen_getdomaininfo(fd, 0, &info) == 1) {
/* Xen 3.2, Fedora 9 */
hv_versions.dom_interface = 5; /* XEN_DOMCTL_INTERFACE_VERSION */
- if (virXen_getvcpusinfo(fd, 0, 0, ipt, NULL, 0) == 0){
+ if (virXen_getvcpusinfo(fd, 0, 0, ipt, NULL, 0) == 0) {
VIR_DEBUG("Using hypervisor call v2, sys ver6 dom ver5");
goto done;
}
@@ -1943,12 +1943,12 @@ xenHypervisorInit(struct xenHypervisorVersions *override_versions)
hv_versions.sys_interface = 8; /* XEN_SYSCTL_INTERFACE_VERSION */
if (virXen_getdomaininfo(fd, 0, &info) == 1) {
hv_versions.dom_interface = 7; /* XEN_DOMCTL_INTERFACE_VERSION */
- if (virXen_getvcpusinfo(fd, 0, 0, ipt, NULL, 0) == 0){
+ if (virXen_getvcpusinfo(fd, 0, 0, ipt, NULL, 0) == 0) {
VIR_DEBUG("Using hypervisor call v2, sys ver8 dom ver7");
goto done;
}
hv_versions.dom_interface = 8; /* XEN_DOMCTL_INTERFACE_VERSION */
- if (virXen_getvcpusinfo(fd, 0, 0, ipt, NULL, 0) == 0){
+ if (virXen_getvcpusinfo(fd, 0, 0, ipt, NULL, 0) == 0) {
VIR_DEBUG("Using hypervisor call v2, sys ver8 dom ver8");
goto done;
}
@@ -1961,7 +1961,7 @@ xenHypervisorInit(struct xenHypervisorVersions *override_versions)
hv_versions.sys_interface = 9; /* XEN_SYSCTL_INTERFACE_VERSION */
if (virXen_getdomaininfo(fd, 0, &info) == 1) {
hv_versions.dom_interface = 8; /* XEN_DOMCTL_INTERFACE_VERSION */
- if (virXen_getvcpusinfo(fd, 0, 0, ipt, NULL, 0) == 0){
+ if (virXen_getvcpusinfo(fd, 0, 0, ipt, NULL, 0) == 0) {
VIR_DEBUG("Using hypervisor call v2, sys ver9 dom ver8");
goto done;
}
diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c
index 519a58f..6d1fec7 100644
--- a/src/xen/xend_internal.c
+++ b/src/xen/xend_internal.c
@@ -2976,7 +2976,7 @@ xenDaemonGetSchedulerType(virConnectPtr conn,
/* get xen_scheduler from xend/node */
ret = sexpr_node(root, "node/xen_scheduler");
- if (ret == NULL){
+ if (ret == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("node information incomplete, missing scheduler name"));
goto error;
@@ -3047,7 +3047,7 @@ xenDaemonGetSchedulerParameters(virConnectPtr conn,
goto error;
}
- switch (sched_nparam){
+ switch (sched_nparam) {
case XEN_SCHED_SEDF_NPARAM:
if (*nparams < XEN_SCHED_SEDF_NPARAM) {
virReportError(VIR_ERR_INVALID_ARG,
@@ -3152,7 +3152,7 @@ xenDaemonSetSchedulerParameters(virConnectPtr conn,
goto error;
}
- switch (sched_nparam){
+ switch (sched_nparam) {
case XEN_SCHED_SEDF_NPARAM:
/* TODO: Implement for Xen/SEDF */
TODO
diff --git a/tests/libvirtdconftest.c b/tests/libvirtdconftest.c
index 13cfa60..8b93f4e 100644
--- a/tests/libvirtdconftest.c
+++ b/tests/libvirtdconftest.c
@@ -217,7 +217,7 @@ mymain(void)
goto cleanup;
}
- if (uncomment_all_params(filedata, ¶ms) < 0){
+ if (uncomment_all_params(filedata, ¶ms) < 0) {
perror("Find params");
ret = -1;
goto cleanup;
diff --git a/tools/virsh-volume.c b/tools/virsh-volume.c
index b528928..4f810f8 100644
--- a/tools/virsh-volume.c
+++ b/tools/virsh-volume.c
@@ -1123,7 +1123,7 @@ cmdVolResize(vshControl *ctl, const vshCmd *cmd)
if (*capacityStr == '-') {
/* The API always requires a positive value; but we allow a
* negative value for convenience. */
- if (delta && vshCommandOptBool(cmd, "shrink")){
+ if (delta && vshCommandOptBool(cmd, "shrink")) {
capacityStr++;
} else {
vshError(ctl, "%s",
--
2.0.4
10 years, 3 months
[libvirt] [PATCH] qemu: Label all TAP FDs
by Michal Privoznik
https://bugzilla.redhat.com/show_bug.cgi?id=1095636
When starting up the domain the domain's NICs are allocated. As of
1f24f682 (v1.0.6) we are able to use multiqueue feature on virtio
NICs. It breaks network processing into multiple queues which can be
processed in parallel by different host CPUs. The queues are, however,
created by opening /dev/net/tun several times. Unfortunately, only the
first FD in the row is labelled so when turning the multiqueue feature
on in the guest, qemu will get AVC denial. Make sure we label all the
FDs needed.
Moreover, the default label of /dev/net/tun doesn't allow
attaching a queue:
type=AVC msg=audit(1399622478.790:893): avc: denied { attach_queue }
for pid=7585 comm="qemu-kvm"
scontext=system_u:system_r:svirt_t:s0:c638,c877
tcontext=system_u:system_r:virtd_t:s0-s0:c0.c1023
tclass=tun_socket
And as suggested by SELinux maintainers, the tun FD should be labeled
as svirt_t. Therefore, we don't need to adjust any range (as done
previously by Guannan in ae368ebf) rather set the seclabel of the
domain directly.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/qemu/qemu_command.c | 18 +++---------------
src/qemu/qemu_hotplug.c | 6 ++++++
src/security/security_selinux.c | 34 ++--------------------------------
3 files changed, 11 insertions(+), 47 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index a92315a..4bc0368 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -192,10 +192,6 @@ qemuPhysIfaceConnect(virDomainDefPtr def,
vmop, cfg->stateDir,
virDomainNetGetActualBandwidth(net));
if (rc >= 0) {
- if (virSecurityManagerSetTapFDLabel(driver->securityManager,
- def, rc) < 0)
- goto error;
-
virDomainAuditNetDevice(def, net, res_ifname, true);
VIR_FREE(net->ifname);
net->ifname = res_ifname;
@@ -203,17 +199,6 @@ qemuPhysIfaceConnect(virDomainDefPtr def,
virObjectUnref(cfg);
return rc;
-
- error:
- ignore_value(virNetDevMacVLanDeleteWithVPortProfile(
- res_ifname, &net->mac,
- virDomainNetGetActualDirectDev(net),
- virDomainNetGetActualDirectMode(net),
- virDomainNetGetActualVirtPortProfile(net),
- cfg->stateDir));
- VIR_FREE(res_ifname);
- virObjectUnref(cfg);
- return -1;
}
@@ -7201,6 +7186,9 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd,
}
for (i = 0; i < tapfdSize; i++) {
+ if (virSecurityManagerSetTapFDLabel(driver->securityManager,
+ def, tapfd[i]) < 0)
+ goto cleanup;
virCommandPassFD(cmd, tapfd[i],
VIR_COMMAND_PASS_FD_CLOSE_PARENT);
if (virAsprintf(&tapfdName[i], "%d", tapfd[i]) < 0)
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index f7e223a..b60bd22 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -922,6 +922,12 @@ int qemuDomainAttachNetDevice(virConnectPtr conn,
goto cleanup;
}
+ for (i = 0; i < tapfdSize; i++) {
+ if (virSecurityManagerSetTapFDLabel(driver->securityManager,
+ vm->def, tapfd[i]) < 0)
+ goto cleanup;
+ }
+
if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_NET_NAME) ||
virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
if (qemuAssignDeviceNetAlias(vm->def, net, -1) < 0)
diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c
index c078cab..5d18493 100644
--- a/src/security/security_selinux.c
+++ b/src/security/security_selinux.c
@@ -2330,47 +2330,17 @@ virSecuritySELinuxSetImageFDLabel(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
}
static int
-virSecuritySELinuxSetTapFDLabel(virSecurityManagerPtr mgr,
+virSecuritySELinuxSetTapFDLabel(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED,
virDomainDefPtr def,
int fd)
{
- struct stat buf;
- security_context_t fcon = NULL;
virSecurityLabelDefPtr secdef;
- char *str = NULL;
- int rc = -1;
secdef = virDomainDefGetSecurityLabelDef(def, SECURITY_SELINUX_NAME);
if (!secdef || !secdef->label)
return 0;
- if (fstat(fd, &buf) < 0) {
- virReportSystemError(errno, _("cannot stat tap fd %d"), fd);
- goto cleanup;
- }
-
- if ((buf.st_mode & S_IFMT) != S_IFCHR) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("tap fd %d is not character device"), fd);
- goto cleanup;
- }
-
- if (getContext(mgr, "/dev/tap.*", buf.st_mode, &fcon) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("cannot lookup default selinux label for tap fd %d"), fd);
- goto cleanup;
- }
-
- if (!(str = virSecuritySELinuxContextAddRange(secdef->label, fcon))) {
- goto cleanup;
- } else {
- rc = virSecuritySELinuxFSetFilecon(fd, str);
- }
-
- cleanup:
- freecon(fcon);
- VIR_FREE(str);
- return rc;
+ return virSecuritySELinuxFSetFilecon(fd, secdef->label);
}
static char *
--
1.8.5.5
10 years, 3 months
[libvirt] [PATCH v3] qemu: Issue rtc-reset-reinjection command after guest-set-time
by Michal Privoznik
https://bugzilla.redhat.com/show_bug.cgi?id=1103245
An advice appeared there on the qemu-devel list [1]. When a domain is
suspended and then resumed guest kernel is not aware of this. So we've
introduced virDomainSetTime API that resets the time within guest
using qemu-ga. On the other hand, qemu itself is trying to make RTC
beat faster to catch the difference. But if we don't tell qemu that
guest's time was reset via the other method, both mechanisms are
applied resulting in again wrong guest time. In order to avoid summing
both corrections we need to tell qemu that it should not use the RTC
injection if the guest time is set via guest agent.
1: http://www.mail-archive.com/qemu-devel@nongnu.org/msg236435.html
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
Notes:
diff to v2:
-introduced capability to test if qemu supports the monitor command
diff to v1:
-fixed command name in subject
-added testcase
src/qemu/qemu_capabilities.c | 2 ++
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_driver.c | 17 +++++++++++++++++
src/qemu/qemu_monitor.c | 33 +++++++++++++++++++++++++++++++++
src/qemu/qemu_monitor.h | 2 ++
src/qemu/qemu_monitor_json.c | 21 +++++++++++++++++++++
src/qemu/qemu_monitor_json.h | 2 ++
tests/qemumonitorjsontest.c | 1 +
8 files changed, 79 insertions(+)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 360cc67..b758b5a 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -265,6 +265,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
"numa",
"memory-backend-file",
"usb-audio",
+ "rtc-reset-reinjection",
);
@@ -1424,6 +1425,7 @@ struct virQEMUCapsStringFlags virQEMUCapsCommands[] = {
{ "add-fd", QEMU_CAPS_ADD_FD },
{ "nbd-server-start", QEMU_CAPS_NBD_SERVER },
{ "change-backing-file", QEMU_CAPS_CHANGE_BACKING_FILE },
+ { "rtc-reset-reinjection", QEMU_CAPS_RTC_RESET_REINJECTION },
};
struct virQEMUCapsStringFlags virQEMUCapsEvents[] = {
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 2911759..cbd3646 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -213,6 +213,7 @@ typedef enum {
QEMU_CAPS_NUMA = 171, /* newer -numa handling with disjoint cpu ranges */
QEMU_CAPS_OBJECT_MEMORY_FILE = 172, /* -object memory-backend-file */
QEMU_CAPS_OBJECT_USB_AUDIO = 173, /* usb-audio device support */
+ QEMU_CAPS_RTC_RESET_REINJECTION = 174, /* rtc-reset-reinjection monitor command */
QEMU_CAPS_LAST, /* this must always be the last item */
} virQEMUCapsFlags;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 0aa1393..d3f2f8c 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -16834,6 +16834,13 @@ qemuDomainSetTime(virDomainPtr dom,
priv = vm->privateData;
+ if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_RTC_RESET_REINJECTION)) {
+ virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
+ _("cannot set time: qemu doesn't support "
+ "rtc-reset-reinjection command"));
+ goto cleanup;
+ }
+
if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
goto cleanup;
@@ -16850,6 +16857,16 @@ qemuDomainSetTime(virDomainPtr dom,
rv = qemuAgentSetTime(priv->agent, seconds, nseconds, rtcSync);
qemuDomainObjExitAgent(vm);
+ if (!virDomainObjIsActive(vm)) {
+ virReportError(VIR_ERR_OPERATION_INVALID,
+ "%s", _("domain is not running"));
+ goto endjob;
+ }
+
+ qemuDomainObjEnterMonitor(driver, vm);
+ rv = qemuMonitorRTCResetReinjection(priv->mon);
+ qemuDomainObjExitMonitor(driver, vm);
+
if (rv < 0)
goto endjob;
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 3d9f87b..77627bc 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -4037,3 +4037,36 @@ qemuMonitorGetGuestCPU(qemuMonitorPtr mon,
return qemuMonitorJSONGetGuestCPU(mon, arch, data);
}
+
+/**
+ * qemuMonitorRTCResetReinjection:
+ * @mon: Pointer to the monitor
+ *
+ * Issue rtc-reset-reinjection command.
+ * This should be used in cases where guest time is restored via
+ * guest agent so RTC injection is not needed (in fact it will
+ * confuse guest's RTC).
+ *
+ * Returns 0 on success
+ * -1 on error.
+ */
+int
+qemuMonitorRTCResetReinjection(qemuMonitorPtr mon)
+{
+
+ VIR_DEBUG("mon=%p", mon);
+
+ if (!mon) {
+ virReportError(VIR_ERR_INVALID_ARG, "%s",
+ _("monitor must not be NULL"));
+ return -1;
+ }
+
+ if (!mon->json) {
+ virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
+ _("JSON monitor is required"));
+ return -1;
+ }
+
+ return qemuMonitorJSONRTCResetReinjection(mon);
+}
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index c3695f2..4fd6f01 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -790,6 +790,8 @@ int qemuMonitorGetGuestCPU(qemuMonitorPtr mon,
virArch arch,
virCPUDataPtr *data);
+int qemuMonitorRTCResetReinjection(qemuMonitorPtr mon);
+
/**
* When running two dd process and using <> redirection, we need a
* shell that will not truncate files. These two strings serve that
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index a62c02f..538110c 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -5851,3 +5851,24 @@ qemuMonitorJSONGetGuestCPU(qemuMonitorPtr mon,
return -1;
}
}
+
+int
+qemuMonitorJSONRTCResetReinjection(qemuMonitorPtr mon)
+{
+ int ret = -1;
+ virJSONValuePtr cmd;
+ virJSONValuePtr reply = NULL;
+
+ if (!(cmd = qemuMonitorJSONMakeCommand("rtc-reset-reinjection",
+ NULL)))
+ return ret;
+
+ ret = qemuMonitorJSONCommand(mon, cmd, &reply);
+
+ if (ret == 0)
+ ret = qemuMonitorJSONCheckError(cmd, reply);
+
+ virJSONValueFree(cmd);
+ virJSONValueFree(reply);
+ return ret;
+}
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index 5f6c846..d8c9308 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -437,4 +437,6 @@ int qemuMonitorJSONGetDeviceAliases(qemuMonitorPtr mon,
int qemuMonitorJSONGetGuestCPU(qemuMonitorPtr mon,
virArch arch,
virCPUDataPtr *data);
+
+int qemuMonitorJSONRTCResetReinjection(qemuMonitorPtr mon);
#endif /* QEMU_MONITOR_JSON_H */
diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c
index baee80a..e3fb4f7 100644
--- a/tests/qemumonitorjsontest.c
+++ b/tests/qemumonitorjsontest.c
@@ -2279,6 +2279,7 @@ mymain(void)
DO_TEST_SIMPLE("inject-nmi", qemuMonitorJSONInjectNMI);
DO_TEST_SIMPLE("system_wakeup", qemuMonitorJSONSystemWakeup);
DO_TEST_SIMPLE("nbd-server-stop", qemuMonitorJSONNBDServerStop);
+ DO_TEST_SIMPLE("rtc-reset-reinjection", qemuMonitorJSONRTCResetReinjection);
DO_TEST_GEN(qemuMonitorJSONSetLink);
DO_TEST_GEN(qemuMonitorJSONBlockResize);
DO_TEST_GEN(qemuMonitorJSONSetVNCPassword);
--
1.8.5.5
10 years, 3 months