[libvirt] libvirt_lxc start problem when selinux enbale
by Huang,Chaochang
Hi,all:
the problem came out when selinux was enforced in targeted+MCS
I start lxc through virsh――“virsh -c lxc:/// start instance-00004bd6”
1. When selinux is Permissive,lxc start is ok
The result of “Ps auxZ” is:
system_u:system_r:virtd_lxc_t:s0-s0:c0.c1023 root 19218 0.0 0.0 47624 1244 ? Ss 15:26 0:00 /usr/libexec/libvirt_lxc --name
system_u:system_r:svirt_lxc_net_t:s0:c192,c392 root 19219 0.3 0.0 19276 1532 ? Ss 15:26 0:00 /sbin/init
system_u:system_r:svirt_lxc_net_t:s0:c192,c392 root 19406 0.0 0.0 177444 1332 ? Sl 15:26 0:00 /sbin/rsyslogd -i /var/run/sysl
system_u:system_r:svirt_lxc_net_t:s0:c192,c392 root 19420 0.0 0.0 64120 1144 ? Ss 15:26 0:00 /usr/sbin/sshd
system_u:system_r:svirt_lxc_net_t:s0:c192,c392 root 19427 0.0 0.0 22136 956 ? Ss 15:26 0:00 xinetd -stayalive -pidfile /var
system_u:system_r:svirt_lxc_net_t:s0:c192,c392 root 19434 0.0 0.0 64316 832 ? Ss 15:26 0:00 /usr/sbin/saslauthd -m /var/run
system_u:system_r:svirt_lxc_net_t:s0:c192,c392 root 19435 0.0 0.0 64316 600 ? S 15:26 0:00 /usr/sbin/saslauthd -m /var/run
system_u:system_r:svirt_lxc_net_t:s0:c192,c392 root 19450 0.0 0.0 82388 2392 ? Ss 15:26 0:00 sendmail: rejecting new message
system_u:system_r:svirt_lxc_net_t:s0:c192,c392 51 19459 0.0 0.0 78116 2016 ? Ss 15:26 0:00 sendmail: Queue runner@01:00:00
system_u:system_r:svirt_lxc_net_t:s0:c192,c392 root 19467 0.0 0.0 175528 3672 ? Ss 15:26 0:00 /usr/sbin/httpd
system_u:system_r:svirt_lxc_net_t:s0:c192,c392 48 19470 0.0 0.0 175528 2204 ? S 15:26 0:00 /usr/sbin/httpd
system_u:system_r:svirt_lxc_net_t:s0:c192,c392 root 19475 0.0 0.0 117212 1348 ? Ss 15:26 0:00 crond
system_u:system_r:svirt_lxc_net_t:s0:c192,c392 root 19491 0.0 0.0 4108 600 pts/0 Ss+ 15:26 0:00 /sbin/mingetty /dev/tty1
We can get into the lxc through “ssh”
2. When selinux is Enforcing,lxc start bad
Th result of “ps auxZ” is:
system_u:system_r:virtd_lxc_t:s0-s0:c0.c1023 root 20624 0.0 0.0 47624 1244 ? Ss 15:29 0:00 /usr/libexec/libvirt_lxc --name
system_u:system_r:svirt_lxc_net_t:s0:c192,c392 root 20625 0.0 0.0 17172 1036 pts/0 Ss+ 15:29 0:00 /sbin/init
Only /sbin/init process started, no else. This is the real problem
There is avc error messages in dmesg、/var/log/messages、/var/log/secure, and the same with selinux is Permissive
Can anybody give some hints?
Here are some system information:
Kernel version
3.3.4
Libvirt version
0.9.13
Lxc guest image
Centos 6.3
Lxc xml info is:
<!--
WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE
OVERWRITTEN AND LOST. Changes to this xml configuration should be made using:
virsh edit instance-00004bd6
or other application using the libvirt API.
-->
<domain type='lxc'>
<name>instance-00004bd6</name>
<uuid>96eada0e-7ea0-4865-8271-3565811c8eb0</uuid>
<memory unit='KiB'>524288</memory>
<currentMemory unit='KiB'>524288</currentMemory>
<vcpu placement='static'>1</vcpu>
<os>
<type arch='x86_64'>exe</type>
<init>/sbin/init</init>
<cmdline>console=ttyS0</cmdline>
</os>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/usr/libexec/libvirt_lxc</emulator>
<filesystem type='mount' accessmode='passthrough'>
<source dir='/home/stack/nova_state/instances/instance-00004bd6/rootfs'/>
<target dir='/'/>
</filesystem>
<interface type='bridge'>
<mac address='fa:16:3e:09:00:a2'/>
<source bridge='br100'/>
<filterref filter='nova-instance-instance-00004bd6-fa163e0900a2'>
<parameter name='DHCPSERVER' value='10.0.0.1'/>
<parameter name='IP' value='10.0.0.11'/>
<parameter name='PROJMASK' value='255.255.254.0'/>
<parameter name='PROJNET' value='10.0.0.0'/>
</filterref>
</interface>
<console type='pty'>
<target type='lxc' port='0'/>
</console>
</devices>
<seclabel type='static' model='selinux' relabel='yes'>
<label>system_u:system_r:svirt_lxc_net_t:s0:c192,c392</label>
</seclabel>
</domain>
Best Regard
Huangchaochang
11 years, 7 months
[libvirt] how to control usb read write perm
by yue
hi,all
i have 2 questions. both is related to spice usb redirect.
1. if i can control RW perm of usb device which is producted via spice ? in order to control user's rw operation in guestVM .
2.if user have several usbs, and plug them at the same time when using spice client. if i can control which usb(s) can be accessed by user in guestVM?
thanks
11 years, 7 months
[libvirt] [libvirt-tck PATCH 1/2] New test for metadata
by Zhe Peng
new script for testing get/set metadata
include API:
dom->get_metadata
dom->set_metadata
---
scripts/domain/310-set-get-metadata.t | 68 +++++++++++++++++++++++++++++++++
1 files changed, 68 insertions(+), 0 deletions(-)
create mode 100644 scripts/domain/310-set-get-metadata.t
diff --git a/scripts/domain/310-set-get-metadata.t b/scripts/domain/310-set-get-metadata.t
new file mode 100644
index 0000000..d1e67a4
--- /dev/null
+++ b/scripts/domain/310-set-get-metadata.t
@@ -0,0 +1,68 @@
+# -*- perl -*-
+#
+# Copyright (C) 2009-2013 Red Hat, Inc.
+# Copyright (C) 2013 Zhe Peng
+#
+# This program is free software; You can redistribute it and/or modify
+# it under the GNU General Public License as published by the Free
+# Software Foundation; either version 2, or (at your option) any
+# later version
+#
+# The file "LICENSE" distributed along with this file provides full
+# details of the terms and conditions
+#
+
+=pod
+
+=head1 NAME
+
+domain/310-set-get-metadata.t - Domain set_metadata/set_metadata
+
+=head1 DESCRIPTION
+
+The test case validates that set_metadata and get_metadata all can worked.
+
+=cut
+
+use strict;
+use warnings;
+
+use Test::More tests => 6;
+
+use Sys::Virt::TCK;
+use Test::Exception;
+
+my $tck = Sys::Virt::TCK->new();
+my $conn = eval { $tck->setup(); };
+my $description = "Test description";
+my $title = "Test Title";
+BAIL_OUT "failed to setup test harness: $@" if $@;
+END { $tck->cleanup if $tck; }
+
+
+my $xml = $tck->generic_domain("tck")->as_xml;
+
+diag "Creating a new transient domain";
+my $dom;
+ok_domain(sub { $dom = $conn->create_domain($xml) }, "created transient domain object");
+
+#set & get metadata for description
+lives_ok(sub {$dom->set_metadata(Sys::Virt::Domain::METADATA_DESCRIPTION,$description,undef,undef,0)},"set metadata for Description");
+
+is($dom->get_metadata(Sys::Virt::Domain::METADATA_DESCRIPTION,undef,0), $description, "get metadata for Description");
+
+#set & get metadata for title
+lives_ok(sub {$dom->set_metadata(Sys::Virt::Domain::METADATA_TITLE,$title,undef,undef,0)},"set metadata for Title");
+
+is($dom->get_metadata(Sys::Virt::Domain::METADATA_TITLE,undef,0), $title, "get metadata for Title");
+
+#clean
+diag "Destroying the transient domain";
+$dom->destroy;
+
+diag "Checking that transient domain has gone away";
+ok_error(sub { $conn->get_domain_by_name("tck") }, "NO_DOMAIN error raised from missing domain",
+ Sys::Virt::Error::ERR_NO_DOMAIN);
+
+# end
+
--
1.7.7.6
11 years, 7 months
[libvirt] [PATCH] Introduce a sub-element <driver> for controller
by Osier Yang
Like what we did for "disk", "filesystem" and "interface", this
introduces sub-element <driver> for "controller", and put the "queues"
into it.
---
docs/formatdomain.html.in | 26 ++++++++++--------
docs/schemas/domaincommon.rng | 14 ++++++----
src/conf/domain_conf.c | 31 +++++++++++++++-------
.../qemuxml2argv-disk-virtio-scsi-num_queues.xml | 4 ++-
4 files changed, 48 insertions(+), 27 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 3dbd58b..9dd283b 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -2135,17 +2135,14 @@
controller. A "scsi" controller has an optional
attribute <code>model</code>, which is one of "auto", "buslogic",
"ibmvscsi", "lsilogic", "lsisas1068", "lsisas1078", "virtio-scsi" or
- "vmpvscsi". The attribute <code>queues</code>
- (<span class="since">1.0.5 (QEMU and KVM only)</span>) specifies
- the number of queues for the controller. For best performance, it's
- recommended to specify a value matching the number of vCPUs. A "usb"
- controller has an optional attribute <code>model</code>, which is one
- of "piix3-uhci", "piix4-uhci", "ehci", "ich9-ehci1", "ich9-uhci1",
- "ich9-uhci2", "ich9-uhci3", "vt82c686b-uhci", "pci-ohci" or "nec-xhci".
- Additionally, <span class="since">since 0.10.0</span>, if the USB bus
- needs to be explicitly disabled for the guest, <code>model='none'</code>
- may be used. The PowerPC64 "spapr-vio" addresses do not have an
- associated controller.
+ "vmpvscsi". A "usb" controller has an optional attribute
+ <code>model</code>, which is one of "piix3-uhci", "piix4-uhci", "ehci",
+ "ich9-ehci1", "ich9-uhci1", "ich9-uhci2", "ich9-uhci3", "vt82c686b-uhci",
+ "pci-ohci" or "nec-xhci". Additionally,
+ <span class="since">since 0.10.0</span>, if the USB bus needs to be
+ explicitly disabled for the guest, <code>model='none'</code> may be
+ used. The PowerPC64 "spapr-vio" addresses do not have an associated
+ controller.
</p>
<p>
@@ -2156,6 +2153,13 @@
</p>
<p>
+ An optional sub-element <code>driver</code> (<span class="since">1.0.5)
+ can specify the driver specific options. Currently it only supports
+ attribute <code>queues</code> (QEMU and KVM only), which specifies the
+ number of queues for the controller. For best performance, it's recommended
+ to specify a value matching the number of vCPUs.
+ </p>
+ <p>
USB companion controllers have an optional
sub-element <code><master></code> to specify the exact
relationship of the companion to its master controller.
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index b1c4c2f..d22bb80 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -1443,11 +1443,6 @@
</choice>
</attribute>
</optional>
- <optional>
- <attribute name="queues">
- <ref name="unsignedInt"/>
- </attribute>
- </optional>
</group>
<!-- usb has an optional attribute "model", and optional subelement "master" -->
<group>
@@ -1493,6 +1488,15 @@
</group>
</choice>
</interleave>
+ <optional>
+ <element name="driver">
+ <optional>
+ <attribute name="queues">
+ <ref name="unsignedInt"/>
+ </attribute>
+ </optional>
+ </element>
+ </optional>
</element>
</define>
<define name="filesystem">
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 253c9ef..0b432dd 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -5156,6 +5156,7 @@ virDomainControllerDefParseXML(xmlNodePtr node,
unsigned int flags)
{
virDomainControllerDefPtr def;
+ xmlNodePtr cur = NULL;
char *type = NULL;
char *idx = NULL;
char *model = NULL;
@@ -5195,12 +5196,19 @@ virDomainControllerDefParseXML(xmlNodePtr node,
def->model = -1;
}
- if ((queues = virXMLPropString(node, "queues"))) {
- if (virStrToLong_ui(queues, NULL, 10, &def->queues) < 0) {
- virReportError(VIR_ERR_XML_ERROR,
- _("Malformed 'queues' value '%s'"), queues);
- goto error;
+ cur = node->children;
+ while (cur != NULL) {
+ if (cur->type == XML_ELEMENT_NODE) {
+ if (xmlStrEqual(cur->name, BAD_CAST "driver"))
+ queues = virXMLPropString(cur, "queues");
}
+ cur = cur->next;
+ }
+
+ if (queues && virStrToLong_ui(queues, NULL, 10, &def->queues) < 0) {
+ virReportError(VIR_ERR_XML_ERROR,
+ _("Malformed 'queues' value '%s'"), queues);
+ goto error;
}
if (virDomainDeviceInfoParseXML(node, NULL, &def->info, flags) < 0)
@@ -13524,9 +13532,6 @@ virDomainControllerDefFormat(virBufferPtr buf,
virBufferEscapeString(buf, " model='%s'", model);
}
- if (def->queues)
- virBufferAsprintf(buf, " queues='%u'", def->queues);
-
switch (def->type) {
case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL:
if (def->opts.vioserial.ports != -1) {
@@ -13543,10 +13548,16 @@ virDomainControllerDefFormat(virBufferPtr buf,
break;
}
- if (virDomainDeviceInfoIsSet(&def->info, flags)) {
+ if (def->queues || virDomainDeviceInfoIsSet(&def->info, flags)) {
virBufferAddLit(buf, ">\n");
- if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
+
+ if (def->queues)
+ virBufferAsprintf(buf, " <driver queues='%u'/>\n", def->queues);
+
+ if (virDomainDeviceInfoIsSet(&def->info, flags) &&
+ virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
return -1;
+
virBufferAddLit(buf, " </controller>\n");
} else {
virBufferAddLit(buf, "/>\n");
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-num_queues.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-num_queues.xml
index b3b1289..fda976c 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-num_queues.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-num_queues.xml
@@ -20,7 +20,9 @@
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
</disk>
<controller type='usb' index='0'/>
- <controller type='scsi' index='0' model='virtio-scsi' queues='8'/>
+ <controller type='scsi' index='0' model='virtio-scsi'>
+ <driver queues='8'/>
+ </controller>
<memballoon model='virtio'/>
</devices>
</domain>
--
1.8.1.4
11 years, 7 months
[libvirt] [PATCH v5 1/2] Add NVRAM device
by Li Zhang
From: Li Zhang <zhlcindy(a)linux.vnet.ibm.com>
For pSeries guest in QEMU, NVRAM is one kind of spapr-vio device.
Users are allowed to specify spapr-vio devices'address.
But NVRAM is not supported in libvirt. So this patch is to
add NVRAM device to allow users to specify its address.
In QEMU, NVRAM device's address is specified by
"-global spapr-nvram.reg=xxxxx".
In libvirt, XML file is defined as the following:
<nvram>
<address type='spapr-vio' reg='0x3000'/>
</nvram>
Signed-off-by: Li Zhang <zhlcindy(a)linux.vnet.ibm.com>
---
v5 -> v4:
* Add NVRAM capability suggested by Osier Yang.
* Define macros for VIO device address.
* Define qemuBuildNVRAMDevStr as static func.
* Correct several error messages.
* Add xml2xml test case
v4 -> v3:
* Seperate NVRAM definition from qemu command line parser.
v3 -> v2:
* Add NVRAM in domaincommon.rng and formatdomain.xml.in suggested by Daniel P.Berrange
* Add NVRAM test cases suggested by Daniel P.Berrange
* Remove nvram allocation when it is not specified suggested by Daniel P.Berrange
* Add several error reports suggested by Daniel P.Berrange
v2 -> v1:
* Add NVRAM parameters parsing in qemuParseCommandLine
docs/formatdomain.html.in | 35 +++++++++++++++++++
docs/schemas/domaincommon.rng | 10 ++++++
src/conf/domain_conf.c | 81 +++++++++++++++++++++++++++++++++++++++++++
src/conf/domain_conf.h | 10 ++++++
4 files changed, 136 insertions(+)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 0cc56d9..4a7a66f 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -4502,6 +4502,41 @@ qemu-kvm -net nic,model=? /dev/null
</dd>
</dl>
+ <h4><a name="elementsNVRAM">NVRAM device</a></h4>
+ <p>
+ One NVRAM device is always added to pSeries guests on PPC64.
+ And on PPC64, NVRAM devices' address type are VIO which
+ allows users to change.<code>nvram</code> element in XML file
+ is provided to specify its address.
+ Currently, libvirt only considers configuration for pSeries guests.
+ </p>
+ <p>
+ Example: usage of NVRAM configuration
+ </p>
+<pre>
+ ...
+ <devices>
+ <nvram>
+ <address type='spapr-vio' reg='0x3000'/>
+ </nvram>
+ </devices>
+ ...
+</pre>
+ <dl>
+ <dt><code>spapr-vio</code></dt>
+ <dd>
+ <p>
+ VIO device address type, this is only for PPC64.
+ </p>
+ </dd>
+ <dt><code>reg</code></dt>
+ <dd>
+ <p>
+ Devices' address
+ </p>
+ </dd>
+ </dl>
+
<h3><a name="seclabel">Security label</a></h3>
<p>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 3976b82..86ef540 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -2793,6 +2793,13 @@
</optional>
</element>
</define>
+ <define name="nvram">
+ <element name="nvram">
+ <optional>
+ <ref name="address"/>
+ </optional>
+ </element>
+ </define>
<define name="memballoon">
<element name="memballoon">
<attribute name="model">
@@ -3280,6 +3287,9 @@
<optional>
<ref name="memballoon"/>
</optional>
+ <optional>
+ <ref name="nvram"/>
+ </optional>
</interleave>
</element>
</define>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 1643f30..acaec20 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -194,6 +194,7 @@ VIR_ENUM_IMPL(virDomainDevice, VIR_DOMAIN_DEVICE_LAST,
"smartcard",
"chr",
"memballoon",
+ "nvram",
"rng")
VIR_ENUM_IMPL(virDomainDeviceAddress, VIR_DOMAIN_DEVICE_ADDRESS_TYPE_LAST,
@@ -1560,6 +1561,16 @@ void virDomainMemballoonDefFree(virDomainMemballoonDefPtr def)
VIR_FREE(def);
}
+void virDomainNVRAMDefFree(virDomainNVRAMDefPtr def)
+{
+ if (!def)
+ return;
+
+ virDomainDeviceInfoClear(&def->info);
+
+ VIR_FREE(def);
+}
+
void virDomainWatchdogDefFree(virDomainWatchdogDefPtr def)
{
if (!def)
@@ -1743,6 +1754,7 @@ void virDomainDeviceDefFree(virDomainDeviceDefPtr def)
case VIR_DOMAIN_DEVICE_SMARTCARD:
case VIR_DOMAIN_DEVICE_CHR:
case VIR_DOMAIN_DEVICE_MEMBALLOON:
+ case VIR_DOMAIN_DEVICE_NVRAM:
case VIR_DOMAIN_DEVICE_LAST:
break;
}
@@ -1951,6 +1963,7 @@ void virDomainDefFree(virDomainDefPtr def)
virDomainWatchdogDefFree(def->watchdog);
virDomainMemballoonDefFree(def->memballoon);
+ virDomainNVRAMDefFree(def->nvram);
for (i = 0; i < def->nseclabels; i++)
virSecurityLabelDefFree(def->seclabels[i]);
@@ -2519,6 +2532,12 @@ virDomainDeviceInfoIterateInternal(virDomainDefPtr def,
if (cb(def, &device, &def->rng->info, opaque) < 0)
return -1;
}
+ if (def->nvram) {
+ device.type = VIR_DOMAIN_DEVICE_NVRAM;
+ device.data.nvram = def->nvram;
+ if (cb(def, &device, &def->nvram->info, opaque) < 0)
+ return -1;
+ }
device.type = VIR_DOMAIN_DEVICE_HUB;
for (i = 0; i < def->nhubs ; i++) {
device.data.hub = def->hubs[i];
@@ -2550,6 +2569,7 @@ virDomainDeviceInfoIterateInternal(virDomainDefPtr def,
case VIR_DOMAIN_DEVICE_SMARTCARD:
case VIR_DOMAIN_DEVICE_CHR:
case VIR_DOMAIN_DEVICE_MEMBALLOON:
+ case VIR_DOMAIN_DEVICE_NVRAM:
case VIR_DOMAIN_DEVICE_LAST:
case VIR_DOMAIN_DEVICE_RNG:
break;
@@ -8130,6 +8150,28 @@ error:
goto cleanup;
}
+static virDomainNVRAMDefPtr
+virDomainNVRAMDefParseXML(const xmlNodePtr node,
+ unsigned int flags)
+{
+ virDomainNVRAMDefPtr def;
+
+ if (VIR_ALLOC(def) < 0) {
+ virReportOOMError();
+ return NULL;
+ }
+
+ if (virDomainDeviceInfoParseXML(node, NULL, &def->info, flags) < 0)
+ goto error;
+
+ return def;
+
+error:
+ virDomainNVRAMDefFree(def);
+ def = NULL;
+ return def;
+}
+
static virSysinfoDefPtr
virSysinfoParseXML(const xmlNodePtr node,
xmlXPathContextPtr ctxt)
@@ -11304,6 +11346,26 @@ virDomainDefParseXML(xmlDocPtr xml,
}
VIR_FREE(nodes);
+ def->nvram = NULL;
+ if ((n = virXPathNodeSet("./devices/nvram", ctxt, &nodes)) < 0) {
+ goto error;
+ }
+
+ if (n > 1) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("only a single nvram device is supported"));
+ goto error;
+ }
+
+ if (n > 0) {
+ virDomainNVRAMDefPtr nvram =
+ virDomainNVRAMDefParseXML(nodes[0], flags);
+ if (!nvram)
+ goto error;
+ def->nvram = nvram;
+ VIR_FREE(nodes);
+ }
+
/* analysis of the hub devices */
if ((n = virXPathNodeSet("./devices/hub", ctxt, &nodes)) < 0) {
goto error;
@@ -14391,6 +14453,21 @@ virDomainMemballoonDefFormat(virBufferPtr buf,
}
static int
+virDomainNVRAMDefFormat(virBufferPtr buf,
+ virDomainNVRAMDefPtr def,
+ unsigned int flags)
+{
+ virBufferAddLit(buf, " <nvram>\n");
+ if (virDomainDeviceInfoIsSet(&def->info, flags) &&
+ virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
+ return -1;
+
+ virBufferAddLit(buf, " </nvram>\n");
+
+ return 0;
+}
+
+static int
virDomainSysinfoDefFormat(virBufferPtr buf,
virSysinfoDefPtr def)
{
@@ -15720,6 +15797,9 @@ virDomainDefFormatInternal(virDomainDefPtr def,
if (def->rng)
virDomainRNGDefFormat(buf, def->rng, flags);
+ if (def->nvram)
+ virDomainNVRAMDefFormat(buf, def->nvram, flags);
+
virBufferAddLit(buf, " </devices>\n");
virBufferAdjustIndent(buf, 2);
@@ -17002,6 +17082,7 @@ virDomainDeviceDefCopy(virDomainDeviceDefPtr src,
case VIR_DOMAIN_DEVICE_SMARTCARD:
case VIR_DOMAIN_DEVICE_CHR:
case VIR_DOMAIN_DEVICE_MEMBALLOON:
+ case VIR_DOMAIN_DEVICE_NVRAM:
case VIR_DOMAIN_DEVICE_LAST:
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Copying definition of '%d' type "
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index f1f01fa..502629a 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -109,6 +109,9 @@ typedef virDomainChrDef *virDomainChrDefPtr;
typedef struct _virDomainMemballoonDef virDomainMemballoonDef;
typedef virDomainMemballoonDef *virDomainMemballoonDefPtr;
+typedef struct _virDomainNVRAMDef virDomainNVRAMDef;
+typedef virDomainNVRAMDef *virDomainNVRAMDefPtr;
+
typedef struct _virDomainSnapshotObj virDomainSnapshotObj;
typedef virDomainSnapshotObj *virDomainSnapshotObjPtr;
@@ -137,6 +140,7 @@ typedef enum {
VIR_DOMAIN_DEVICE_SMARTCARD,
VIR_DOMAIN_DEVICE_CHR,
VIR_DOMAIN_DEVICE_MEMBALLOON,
+ VIR_DOMAIN_DEVICE_NVRAM,
VIR_DOMAIN_DEVICE_RNG,
VIR_DOMAIN_DEVICE_LAST
@@ -163,6 +167,7 @@ struct _virDomainDeviceDef {
virDomainSmartcardDefPtr smartcard;
virDomainChrDefPtr chr;
virDomainMemballoonDefPtr memballoon;
+ virDomainNVRAMDefPtr nvram;
virDomainRNGDefPtr rng;
} data;
};
@@ -1469,6 +1474,9 @@ struct _virDomainMemballoonDef {
virDomainDeviceInfo info;
};
+struct _virDomainNVRAMDef {
+ virDomainDeviceInfo info;
+};
enum virDomainSmbiosMode {
VIR_DOMAIN_SMBIOS_NONE = 0,
@@ -1916,6 +1924,7 @@ struct _virDomainDef {
/* Only 1 */
virDomainWatchdogDefPtr watchdog;
virDomainMemballoonDefPtr memballoon;
+ virDomainNVRAMDefPtr nvram;
virDomainTPMDefPtr tpm;
virCPUDefPtr cpu;
virSysinfoDefPtr sysinfo;
@@ -2076,6 +2085,7 @@ int virDomainChrSourceDefCopy(virDomainChrSourceDefPtr src,
void virDomainSoundCodecDefFree(virDomainSoundCodecDefPtr def);
void virDomainSoundDefFree(virDomainSoundDefPtr def);
void virDomainMemballoonDefFree(virDomainMemballoonDefPtr def);
+void virDomainNVRAMDefFree(virDomainNVRAMDefPtr def);
void virDomainWatchdogDefFree(virDomainWatchdogDefPtr def);
void virDomainVideoDefFree(virDomainVideoDefPtr def);
virDomainHostdevDefPtr virDomainHostdevDefAlloc(void);
--
1.8.1.4
11 years, 7 months
[libvirt] [PATCH] qemu: Don't require a block or file when looking for an alias.
by Wido den Hollander
This for example prohibits you to use iotune for Ceph or Sheepdog devices.
Signed-off-by: Wido den Hollander <wido(a)widodh.nl>
---
src/qemu/qemu_driver.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 552a81b..464d30a 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -13032,10 +13032,6 @@ qemuDiskPathToAlias(virDomainObjPtr vm, const char *path, int *idx)
if (idx)
*idx = i;
- if (disk->type != VIR_DOMAIN_DISK_TYPE_BLOCK &&
- disk->type != VIR_DOMAIN_DISK_TYPE_FILE)
- goto cleanup;
-
if (disk->src) {
if (virAsprintf(&ret, "drive-%s", disk->info.alias) < 0) {
virReportOOMError();
--
1.7.9.5
11 years, 7 months
[libvirt] [PATCH] doc: Clarify usage of SELinux baselabel
by Peter Krempa
State what fields are used when generating SELinux labels from a
baselabel.
---
docs/formatdomain.html.in | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 888c005..9118ff0 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -4596,8 +4596,13 @@ qemu-kvm -net nic,model=? /dev/null
</dd>
<dt><code>baselabel</code></dt>
<dd>If dynamic labelling is used, this can optionally be
- used to specify the base security label. The format
- of the content depends on the security driver in use.
+ used to specify the base security label that will be used to generate
+ the actual label. The format of the content depends on the security
+ driver in use.
+
+ The SELinux driver uses only the <code>type</code> field of the
+ baselabel in the generated label. Other fields are inherited from
+ the parent process when using SELinux baselabels.
</dd>
<dt><code>imagelabel</code></dt>
<dd>This is an output only element, which shows the
--
1.8.2.1
11 years, 7 months
[libvirt] [PATCH] virsh: don't shorten incorrect arguments
by Ján Tomko
https://bugzilla.redhat.com/show_bug.cgi?id=949373
Print the whole incorrect argument as specified by the user
instead of the short option.
Before:
$ virsh --debu
error: option '-d' requires an argument
$ virsh ---debu
error: unsupported option '-
$ virsh --debu c
error: option -d takes a numeric argument
After:
$ virsh --debu
error: option '--debu' requires an argument
$ virsh ---debu
error: unsupported option '---debu'. See --help.
$ virsh --debu c
error: option --debu takes a numeric argument
---
tools/virsh.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 4cd93ca..3856f62 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -2997,7 +2997,7 @@ vshParseArgv(vshControl *ctl, int argc, char **argv)
switch (arg) {
case 'd':
if (virStrToLong_i(optarg, NULL, 10, &debug) < 0) {
- vshError(ctl, "%s", _("option -d takes a numeric argument"));
+ vshError(ctl, _("option %s takes a numeric argument"), argv[optind - 2]);
exit(EXIT_FAILURE);
}
if (debug < VSH_ERR_DEBUG || debug > VSH_ERR_ERROR)
@@ -3048,10 +3048,10 @@ vshParseArgv(vshControl *ctl, int argc, char **argv)
}
break;
case ':':
- vshError(ctl, _("option '-%c' requires an argument"), optopt);
+ vshError(ctl, _("option '%s' requires an argument"), argv[optind - 1]);
exit(EXIT_FAILURE);
case '?':
- vshError(ctl, _("unsupported option '-%c'. See --help."), optopt);
+ vshError(ctl, _("unsupported option '%s'. See --help."), argv[optind - 1]);
exit(EXIT_FAILURE);
default:
vshError(ctl, _("unknown option"));
--
1.8.1.5
11 years, 7 months
[libvirt] [PATCH] Change the tag name "num_queues" into "queues"
by Osier Yang
Instead of making a choice between the underscore and camelCase, this
simply changes "num_queues" into "queues", which is also consistent
with Michal's multiple queue support for interface.
---
docs/formatdomain.html.in | 2 +-
docs/schemas/domaincommon.rng | 2 +-
src/conf/domain_conf.c | 14 +++++++-------
src/conf/domain_conf.h | 2 +-
src/qemu/qemu_command.c | 8 ++++----
.../qemuxml2argv-disk-virtio-scsi-num_queues.xml | 2 +-
6 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 888c005..3dbd58b 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -2135,7 +2135,7 @@
controller. A "scsi" controller has an optional
attribute <code>model</code>, which is one of "auto", "buslogic",
"ibmvscsi", "lsilogic", "lsisas1068", "lsisas1078", "virtio-scsi" or
- "vmpvscsi". The attribute <code>num_queues</code>
+ "vmpvscsi". The attribute <code>queues</code>
(<span class="since">1.0.5 (QEMU and KVM only)</span>) specifies
the number of queues for the controller. For best performance, it's
recommended to specify a value matching the number of vCPUs. A "usb"
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 3976b82..b1c4c2f 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -1444,7 +1444,7 @@
</attribute>
</optional>
<optional>
- <attribute name="num_queues">
+ <attribute name="queues">
<ref name="unsignedInt"/>
</attribute>
</optional>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index dc0ecaa..253c9ef 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -5159,7 +5159,7 @@ virDomainControllerDefParseXML(xmlNodePtr node,
char *type = NULL;
char *idx = NULL;
char *model = NULL;
- char *num_queues = NULL;
+ char *queues = NULL;
if (VIR_ALLOC(def) < 0) {
virReportOOMError();
@@ -5195,10 +5195,10 @@ virDomainControllerDefParseXML(xmlNodePtr node,
def->model = -1;
}
- if ((num_queues = virXMLPropString(node, "num_queues"))) {
- if (virStrToLong_ui(num_queues, NULL, 10, &def->num_queues) < 0) {
+ if ((queues = virXMLPropString(node, "queues"))) {
+ if (virStrToLong_ui(queues, NULL, 10, &def->queues) < 0) {
virReportError(VIR_ERR_XML_ERROR,
- _("Malformed 'num_queues' value '%s'"), num_queues);
+ _("Malformed 'queues' value '%s'"), queues);
goto error;
}
}
@@ -5280,7 +5280,7 @@ cleanup:
VIR_FREE(type);
VIR_FREE(idx);
VIR_FREE(model);
- VIR_FREE(num_queues);
+ VIR_FREE(queues);
return def;
@@ -13524,8 +13524,8 @@ virDomainControllerDefFormat(virBufferPtr buf,
virBufferEscapeString(buf, " model='%s'", model);
}
- if (def->num_queues)
- virBufferAsprintf(buf, " num_queues='%u'", def->num_queues);
+ if (def->queues)
+ virBufferAsprintf(buf, " queues='%u'", def->queues);
switch (def->type) {
case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL:
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 5b069b6..acf18f8 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -742,7 +742,7 @@ struct _virDomainControllerDef {
int type;
int idx;
int model; /* -1 == undef */
- unsigned int num_queues;
+ unsigned int queues;
union {
virDomainVirtioSerialOpts vioserial;
} opts;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index b1d3d1b..35cfac8 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3524,11 +3524,11 @@ qemuBuildControllerDevStr(virDomainDefPtr domainDef,
virBuffer buf = VIR_BUFFER_INITIALIZER;
int model;
- if (def->num_queues &&
+ if (def->queues &&
!(def->type == VIR_DOMAIN_CONTROLLER_TYPE_SCSI &&
def->model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("'num_queues' is only supported by virtio-scsi controller"));
+ _("'queues' is only supported by virtio-scsi controller"));
return NULL;
}
@@ -3615,8 +3615,8 @@ qemuBuildControllerDevStr(virDomainDefPtr domainDef,
goto error;
}
- if (def->num_queues)
- virBufferAsprintf(&buf, ",num_queues=%u", def->num_queues);
+ if (def->queues)
+ virBufferAsprintf(&buf, ",num_queues=%u", def->queues);
if (qemuBuildDeviceAddressStr(&buf, &def->info, qemuCaps) < 0)
goto error;
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-num_queues.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-num_queues.xml
index dfa9cf1..b3b1289 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-num_queues.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-num_queues.xml
@@ -20,7 +20,7 @@
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
</disk>
<controller type='usb' index='0'/>
- <controller type='scsi' index='0' model='virtio-scsi' num_queues='8'/>
+ <controller type='scsi' index='0' model='virtio-scsi' queues='8'/>
<memballoon model='virtio'/>
</devices>
</domain>
--
1.8.1.4
11 years, 7 months
[libvirt] virNodeDevice APIs and VFIO
by Laine Stump
Yesterday for the first time I consciously noticed the
virNodeDeviceDettach and virNodeDeviceReAttach APIs, and found that they
are hardcoded to bind to/unbind from the pci-stub driver for qemu, and
the "pciback" driver for Xen. If we want these APIs to be useful for
VFIO, they will need to bind to the vfio driver instead, but there is
currently no method in those APIs to specify which driver to bind to.
I guess we could do this with new virNodeDeviceDetachFlags() and
virNodeDeviceReAttachFlags() APIs which have a flag to indicate vfio,
but before going to that trouble I'd like to know if these APIs are
actually used or if they are deprecated (they don't seem to be of any
use if the hostdev devices you're assigning have "managed='yes'" - as
far as I can see, setting managed='yes' just makes the bind/unbind from
the stub driver an automatic part of assigning/un-assigning the device
to a guest).
(Beyond that, this would be exposing a lower level of detail in the APIs
than the original functions, and I'm not sure if it's appropriate - the
choice of stub driver was previously hidden in each hypervisor driver).
11 years, 7 months