[libvirt] [PATCH 0/2] Cleanup for return with parentheses
by Martin Kletzander
There was one big inconsistency in our source files when return was
used. Sometimes it was used with parentheses and sometimes
without. The old-style return(value) was removed in the first commit,
the second commit introduces new syntax-check to ensure the style will
remain the same in the future.
Martin Kletzander (2):
Cleanup for a return statement in source files
Added syntax-check rule for return with parentheses
cfg.mk | 6 +
examples/dominfo/info1.c | 2 +-
examples/domsuspend/suspend.c | 6 +-
python/generator.py | 8 +-
python/libvirt-override.c | 216 +++++++++++++-------------
python/libvirt-qemu-override.c | 4 +-
python/typewrappers.c | 76 +++++-----
src/conf/domain_conf.c | 22 ++--
src/conf/interface_conf.c | 70 +++++-----
src/conf/nwfilter_params.c | 2 +-
src/cpu/cpu_x86.c | 2 +-
src/datatypes.c | 80 +++++-----
src/interface/netcf_driver.c | 2 +-
src/lxc/lxc_driver.c | 4 +-
src/nwfilter/nwfilter_ebiptables_driver.c | 4 +-
src/qemu/qemu_command.c | 6 +-
src/qemu/qemu_driver.c | 4 +-
src/qemu/qemu_process.c | 2 +-
src/remote/remote_driver.c | 2 +-
src/security/security_selinux.c | 2 +-
src/test/test_driver.c | 8 +-
src/util/conf.c | 106 +++++++-------
src/util/hooks.c | 20 ++--
src/util/sexpr.c | 14 +-
src/util/util.c | 8 +-
src/util/uuid.c | 6 +-
src/util/virhash.c | 30 ++--
src/util/virmacaddr.c | 2 +-
src/util/virnetlink.c | 2 +-
src/util/virsocketaddr.c | 48 +++---
src/util/virterror.c | 14 +-
src/util/xml.c | 50 +++---
src/xen/xen_driver.c | 32 ++--
src/xen/xen_hypervisor.c | 228 ++++++++++++++--------------
src/xen/xend_internal.c | 234 ++++++++++++++--------------
src/xen/xm_internal.c | 98 ++++++------
src/xen/xs_internal.c | 120 ++++++++--------
src/xenapi/xenapi_driver.c | 2 +-
src/xenxs/xen_sxpr.c | 2 +-
src/xenxs/xen_xm.c | 2 +-
tests/commandtest.c | 4 +-
tests/cputest.c | 2 +-
tests/domainsnapshotxml2xmltest.c | 4 +-
tests/interfacexml2xmltest.c | 2 +-
tests/networkxml2argvtest.c | 2 +-
tests/networkxml2xmltest.c | 2 +-
tests/nodedevxml2xmltest.c | 2 +-
tests/nodeinfotest.c | 2 +-
tests/nwfilterxml2xmltest.c | 2 +-
tests/qemuargv2xmltest.c | 2 +-
tests/qemuxml2argvtest.c | 2 +-
tests/qemuxml2xmltest.c | 4 +-
tests/qemuxmlnstest.c | 2 +-
tests/qparamtest.c | 2 +-
tests/sexpr2xmltest.c | 4 +-
tests/sockettest.c | 2 +-
tests/statstest.c | 2 +-
tests/storagepoolxml2xmltest.c | 2 +-
tests/storagevolxml2xmltest.c | 2 +-
tests/virbuftest.c | 2 +-
tests/virnetmessagetest.c | 2 +-
tests/virnetsockettest.c | 4 +-
tests/virnettlscontexttest.c | 2 +-
tests/virshtest.c | 2 +-
tests/virtimetest.c | 2 +-
tests/xencapstest.c | 2 +-
tests/xmconfigtest.c | 4 +-
tests/xml2sexprtest.c | 4 +-
tools/virsh.c | 8 +-
69 files changed, 815 insertions(+), 809 deletions(-)
--
1.7.3.4
12 years, 8 months
[libvirt] [PATCH] Expand docs for timer tick policy
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
---
docs/formatdomain.html.in | 25 ++++++++++++++++++++-----
1 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 814e270..c2eabc5 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -1016,11 +1016,23 @@
</dd>
<dt><code>tickpolicy</code></dt>
<dd>
- The <code>tickpolicy</code> attribute determines how
- missed ticks in the guest are handled, and can be "delay",
- "catchup", "merge", or "discard". If the policy is
- "catchup", there can be further details in
- the <code>catchup</code> sub-element.
+ <p>
+ The <code>tickpolicy</code> attribute determines what
+ happens whens QEMU misses a deadline for injecting a
+ tick to the guest:
+ </p>
+ <dl>
+ <dt><code>delay</code></dt>
+ <dd>Continue to deliver ticks at the normal rate. The guest time will be delayed due to the late tick</dd>
+ <dt><code>catchup</code></dt>
+ <dd>Deliver ticks at a higher rate to catchup with the missed tick. The guest time should not be delayed once catch is complete.</dd>
+ <dt><code>merge</code></dt>
+ <dd>Merge the missed tick(s) into one tick and inject. The guest time may be delayed, depending on how the OS reacts to the merging of ticks</dd>
+ <dt><code>discard</code></dt>
+ <dd>Throw away the missed tick(s) and continue with future injection normally. The guest time may be delayed, unless the OS has explicit handling of lost ticks</dd>
+ </dl>
+ <p>If the policy is "catchup", there can be further details in
+ the <code>catchup</code> sub-element.</p>
<dl>
<dt><code>catchup</code></dt>
<dd>
@@ -1030,6 +1042,9 @@
and <code>limit</code>.
</dd>
</dl>
+ <p>
+ Note that hypervisors are not required to support all policies across all time sources
+ </p>
</dd>
<dt><code>frequency</code></dt>
<dd>
--
1.7.7.6
12 years, 8 months
[libvirt] Createion of external snapshot qcow2
by Pankaj Rawat
Hi all,
I have a query regarding the external snapshot in qcow2 also known as
backing file.
In qemu I created a external snapshot and then create its xml in order
to boot it from VIRSH. But that is complex process.
I want to know whether there is any command in LIBVIRT which can create
external snapshot(Backing file) and also we can boot from it?
DISCLAIMER:
-----------------------------------------------------------------------------------------------------------------------
The contents of this e-mail and any attachment(s) are confidential and
intended
for the named recipient(s) only.
It shall not attach any liability on the originator or NECHCL or its
affiliates. Any views or opinions presented in
this email are solely those of the author and may not necessarily reflect the
opinions of NECHCL or its affiliates.
Any form of reproduction, dissemination, copying, disclosure, modification,
distribution and / or publication of
this message without the prior written consent of the author of this e-mail is
strictly prohibited. If you have
received this email in error please delete it and notify the sender
immediately. .
-----------------------------------------------------------------------------------------------------------------------
12 years, 8 months
[libvirt] [PATCH 0/3] build: fix 3 Fedora 17 build errors
by Laine Stump
The first two of these ("missing initializer") I would expect anybody
to get if they're building with -Wall on Fedora 17, but the problems
have been there at least since the last libvirt release. The last
error only happens if you manually specify CFLAGS with no -O (or with
-O0).
Although these break the build for me, none of it is new, so I'll wait
for ACKs before pushing. (I do think it would be good to get these
fixes into the -rc2 candidate, though).
12 years, 8 months
[libvirt] sr-iov ethernet VF is not assigned correctly to guest
by Scott
Hi, I'm hoping someone could possibly show me what I may be doing wrong here, and why I'm not seeing the expected results
Thanks in advance!
Server Information:HP Product Name: ProLiant DL165 G7
Ethernet Card Information: Intel 82599EB 10-Gigabit SFI/SFP+
uname: Linux 3.0.0-16-server x86_64 GNU/Linux
OS Release: Ubuntu 11.10
qemu-kvm version 0.14.1+noroms-0ubuntu6.2
First, here's a list of my VFs:
# ip link show:
2: eth0: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc mq master bond0 state UP qlen 1000
link/ether 00:1b:21:7d:70:16 brd ff:ff:ff:ff:ff:ff
vf 0 MAC 02:22:25:00:00:00
vf 1 MAC 02:22:25:00:00:01
vf 2 MAC 02:22:25:00:00:02
vf 3 MAC 02:22:25:00:00:03
vf 4 MAC 02:22:25:00:00:04
vf 5 MAC 02:22:25:00:00:05
vf 6 MAC 02:22:25:00:00:06
3: eth1: <NO-CARRIER,BROADCAST,MULTICAST,SLAVE,UP> mtu 1500 qdisc mq master bond0 state DOWN qlen 1000
link/ether 00:1b:21:7d:70:16 brd ff:ff:ff:ff:ff:ff
vf 0 MAC 02:22:25:01:00:00
vf 1 MAC 02:22:25:01:00:01
vf 2 MAC 02:22:25:01:00:02
vf 3 MAC 02:22:25:01:00:03
vf 4 MAC 02:22:25:01:00:04
vf 5 MAC 02:22:25:01:00:05
vf 6 MAC 02:22:25:01:00:06
# lspci |grep 05
05:00.0 Ethernet controller: Intel Corporation 82576 Gigabit Network Connection (rev 01)
05:00.1 Ethernet controller: Intel Corporation 82576 Gigabit Network Connection (rev 01)
05:10.0 Ethernet controller: Intel Corporation 82576 Virtual Function (rev 01)
05:10.1 Ethernet controller: Intel Corporation 82576 Virtual Function (rev 01)
05:10.2 Ethernet controller: Intel Corporation 82576 Virtual Function (rev 01)
05:10.3 Ethernet controller: Intel Corporation 82576 Virtual Function (rev 01)
05:10.4 Ethernet controller: Intel Corporation 82576 Virtual Function (rev 01)
05:10.5 Ethernet controller: Intel Corporation 82576 Virtual Function (rev 01)
05:10.6 Ethernet controller: Intel Corporation 82576 Virtual Function (rev 01)
05:10.7 Ethernet controller: Intel Corporation 82576 Virtual Function (rev 01)
05:11.0 Ethernet controller: Intel Corporation 82576 Virtual Function (rev 01)
05:11.1 Ethernet controller: Intel Corporation 82576 Virtual Function (rev 01)
05:11.2 Ethernet controller: Intel Corporation 82576 Virtual Function (rev 01)
05:11.3 Ethernet controller: Intel Corporation 82576 Virtual Function (rev 01)
05:11.4 Ethernet controller: Intel Corporation 82576 Virtual Function (rev 01)
05:11.5 Ethernet controller: Intel Corporation 82576 Virtual Function (rev 01)
# virsh nodedev-list |grep 05
pci_0000_05_00_0
pci_0000_05_00_1
pci_0000_05_10_0
pci_0000_05_10_1
pci_0000_05_10_2
pci_0000_05_10_3
pci_0000_05_10_4
pci_0000_05_10_5
pci_0000_05_10_6
pci_0000_05_10_7
pci_0000_05_11_0
pci_0000_05_11_1
pci_0000_05_11_2
pci_0000_05_11_3
pci_0000_05_11_4
pci_0000_05_11_5
4 Now detach 05.10.0 and 05.11.0 from the host:
# virsh nodedev-dettach pci_0000_05_10_0
Device pci_0000_05_10_0 dettached
# virsh nodedev-dettach pci_0000_05_11_0
Device pci_0000_05_11_0 dettached
5. Get the host, slot, function information:
# virsh nodedev-dumpxml pci_0000_05_10_0|grep -e bus -e slot -e fun |head -3
<bus>5</bus>
<slot>16</slot>
<function>0</function>
# virsh nodedev-dumpxml pci_0000_05_11_0|grep -e bus -e slot -e fun |head -3
<bus>5</bus>
<slot>17</slot>
<function>0</function>
== GUEST-A ==
XML:
...
<hostdev mode='subsystem' type='pci' managed='yes'>
<source>
<address domain='0x0000' bus='0x05' slot='0x10' function='0x0'/>
</source>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</hostdev>
<hostdev mode='subsystem' type='pci' managed='yes'>
<source>
<address domain='0x0000' bus='0x05' slot='0x11' function='0x0'/>
</source>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
</hostdev>
...
CLI:
/usr/bin/kvm -S \
-M pc-0.14 \
-enable-kvm \
-m 256 \
-smp 1,sockets=1,cores=1,threads=1 \
-name GUEST-A \
-uuid 9bac7b2f-dbb4-0f2a-08e6-47018d6630db \
-nodefconfig -nodefaults
-chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/HOST-A.monitor,server,nowait \
-mon chardev=charmonitor,id=monitor,mode=readline \
-rtc base=utc \
-boot cn \
-drive file=/srv/node/sdc1/HOST-A.raw,if=none,id=drive-virtio-disk0,boot=on,format=raw,cache=none \
-device virtio-blk-pci,bus=pci.0,addr=0x3,drive=drive-virtio-disk0,id=virtio-disk0 \
-chardev pty,id=charserial0 \
-device isa-serial,chardev=charserial0,id=serial0 \
-usb \
-vnc 0.0.0.0:0 \
-vga cirrus \
-device pci-assign,host=05:10.0,id=hostdev0,configfd=20,bus=pci.0,addr=0x4 \
-device pci-assign,host=05:11.0,id=hostdev1,configfd=21,bus=pci.0,addr=0x5 \
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x6
dmesg:
[ 3.072509] igbvf 0000:00:04.0: Intel(R) 82576 Virtual Function
[ 3.072514] igbvf 0000:00:04.0: Address: 02:22:25:00:00:00
[ 3.072516] igbvf 0000:00:04.0: MAC: 1
[ 3.241325] igbvf 0000:00:05.0: Intel(R) 82576 Virtual Function
[ 3.241329] igbvf 0000:00:05.0: Address: 02:22:25:00:00:04
[ 3.241332] igbvf 0000:00:05.0: MAC: 1
ip link:
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 02:22:25:00:00:00 brd ff:ff:ff:ff:ff:ff
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 02:22:25:00:00:04 brd ff:ff:ff:ff:ff:ff
Expected Results:
GUEST-A should have the following assignment:
eth0 should = eth0-vf0 (bus:5, slot:10, fun:0), mac: 02:22:25:00:00:00
eth1 should = eth1-vf0 (bus:5, slot:11, fun:0), mac: 02:22:25:01:00:00
12 years, 8 months
[libvirt] [PATCH 1/2] Add support for setting init argv for LXC
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
Pass argv to the init binary of LXC, using a new <initarg> element.
* docs/formatdomain.html.in: Document <os> usage for containers
* docs/schemas/domaincommon.rng: Add <initarg> element
* src/conf/domain_conf.c, src/conf/domain_conf.h: parsing and
formatting of <initarg>
* src/lxc/lxc_container.c: Setup LXC argv
* tests/Makefile.am, tests/lxcxml2xmldata/lxc-systemd.xml,
tests/lxcxml2xmltest.c, tests/testutilslxc.c,
tests/testutilslxc.h: Test parsing/formatting of LXC related
XML parts
---
docs/formatdomain.html.in | 22 +++++
docs/schemas/domaincommon.rng | 5 +
src/conf/domain_conf.c | 28 ++++++-
src/conf/domain_conf.h | 1 +
src/lxc/lxc_container.c | 3 +
tests/Makefile.am | 21 +++++
tests/lxcxml2xmldata/lxc-systemd.xml | 30 +++++++
tests/lxcxml2xmltest.c | 141 ++++++++++++++++++++++++++++++++++
tests/testutilslxc.c | 63 +++++++++++++++
tests/testutilslxc.h | 4 +
10 files changed, 316 insertions(+), 2 deletions(-)
create mode 100644 tests/lxcxml2xmldata/lxc-systemd.xml
create mode 100644 tests/lxcxml2xmltest.c
create mode 100644 tests/testutilslxc.c
create mode 100644 tests/testutilslxc.h
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index c2eabc5..1211e50 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -250,6 +250,28 @@
installation media source / kickstart file</dd>
</dl>
+ <h4><a name="eleemntsOSContainer">Container boot</a></h4>
+
+ <p>
+ When booting a domain using container based virtualization, instead
+ of a kernel / boot image, a path to the init binary is required, using
+ the <code>init</code> element. By default this will be launched with
+ no arguments. To specify the initial argv, use the <code>initarg</code>
+ element, repeated as many time as is required. The <code>cmdline</code>
+ element, if set will be used to provide an equivalent to <code>/proc/cmdline</code>
+ but will not effect init argv.
+ </p>
+
+ <pre>
+ <os>
+ <type arch='x86_64'>exe</type>
+ <init>/bin/systemd</init>
+ <initarg>--unit</initarg>
+ <initarg>emergency.service</initarg>
+ </os>
+ </pre>
+
+
<h3><a name="elementsSysinfo">SMBIOS System Information</a></h3>
<p>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 1f5232e..730f3d8 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -378,6 +378,11 @@
<ref name="absFilePath"/>
</element>
</optional>
+ <zeroOrMore>
+ <element name="initarg">
+ <text/>
+ </element>
+ </zeroOrMore>
</interleave>
</element>
</define>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 3921c0f..6f71e33 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -1559,6 +1559,9 @@ void virDomainDefFree(virDomainDefPtr def)
VIR_FREE(def->os.arch);
VIR_FREE(def->os.machine);
VIR_FREE(def->os.init);
+ for (i = 0 ; def->os.initargv && def->os.initargv[i] ; i++)
+ VIR_FREE(def->os.initargv[i]);
+ VIR_FREE(def->os.initargv);
VIR_FREE(def->os.kernel);
VIR_FREE(def->os.initrd);
VIR_FREE(def->os.cmdline);
@@ -8188,6 +8191,25 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
}
}
def->os.cmdline = virXPathString("string(./os/cmdline[1])", ctxt);
+
+ if ((n = virXPathNodeSet("./os/initarg", ctxt, &nodes)) < 0) {
+ goto error;
+ }
+
+ if (VIR_ALLOC_N(def->os.initargv, n+1) < 0)
+ goto no_memory;
+ for (i = 0 ; i < n ; i++) {
+ if (!nodes[i]->children ||
+ !nodes[i]->children->content) {
+ virDomainReportError(VIR_ERR_XML_ERROR, "%s",
+ _("No data supplied for <initarg> element"));
+ goto error;
+ }
+ if (!(def->os.initargv[i] = strdup((const char*)nodes[i]->children->content)))
+ goto no_memory;
+ }
+ def->os.initargv[n] = NULL;
+ VIR_FREE(nodes);
}
if (STREQ(def->os.type, "xen") ||
@@ -12171,6 +12193,7 @@ virDomainDefFormatInternal(virDomainDefPtr def,
char uuidstr[VIR_UUID_STRING_BUFLEN];
const char *type = NULL;
int n, allones = 1;
+ int i;
bool blkio = false;
virCheckFlags(DUMPXML_FLAGS |
@@ -12332,7 +12355,6 @@ virDomainDefFormatInternal(virDomainDefPtr def,
virBufferAsprintf(buf, " <quota>%lld</quota>\n",
def->cputune.quota);
if (def->cputune.vcpupin) {
- int i;
for (i = 0; i < def->cputune.nvcpupin; i++) {
virBufferAsprintf(buf, " <vcpupin vcpu='%u' ",
def->cputune.vcpupin[i]->vcpuid);
@@ -12408,6 +12430,9 @@ virDomainDefFormatInternal(virDomainDefPtr def,
virBufferEscapeString(buf, " <init>%s</init>\n",
def->os.init);
+ for (i = 0 ; def->os.initargv && def->os.initargv[i] ; i++)
+ virBufferEscapeString(buf, " <initarg>%s</initarg>\n",
+ def->os.initargv[i]);
virBufferEscapeString(buf, " <loader>%s</loader>\n",
def->os.loader);
virBufferEscapeString(buf, " <kernel>%s</kernel>\n",
@@ -12462,7 +12487,6 @@ virDomainDefFormatInternal(virDomainDefPtr def,
virBufferAddLit(buf, " </os>\n");
if (def->features) {
- int i;
virBufferAddLit(buf, " <features>\n");
for (i = 0 ; i < VIR_DOMAIN_FEATURE_LAST ; i++) {
if (def->features & (1 << i)) {
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 10030a4..3fcb026 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1354,6 +1354,7 @@ struct _virDomainOSDef {
int bootDevs[VIR_DOMAIN_BOOT_LAST];
int bootmenu;
char *init;
+ char **initargv;
char *kernel;
char *initrd;
char *cmdline;
diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index bb64b60..0755b3c 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -122,6 +122,9 @@ static virCommandPtr lxcContainerBuildInitCmd(virDomainDefPtr vmDef)
cmd = virCommandNew(vmDef->os.init);
+ if (vmDef->os.initargv && vmDef->os.initargv[0])
+ virCommandAddArgSet(cmd, (const char **)vmDef->os.initargv);
+
virCommandAddEnvString(cmd, "PATH=/bin:/sbin");
virCommandAddEnvString(cmd, "TERM=linux");
virCommandAddEnvString(cmd, "container=lxc-libvirt");
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 4755a3e..4a0686f 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -60,6 +60,7 @@ EXTRA_DIST = \
domainsnapshotxml2xmlin \
domainsnapshotxml2xmlout \
interfaceschemadata \
+ lxcxml2xmldata \
networkschematest \
networkxml2xmlin \
networkxml2xmlout \
@@ -115,6 +116,10 @@ check_PROGRAMS += qemuxml2argvtest qemuxml2xmltest qemuxmlnstest \
qemumonitortest
endif
+if WITH_LXC
+check_PROGRAMS += lxcxml2xmltest
+endif
+
if WITH_OPENVZ
check_PROGRAMS += openvzutilstest
endif
@@ -245,6 +250,10 @@ TESTS += qemuxml2argvtest qemuxml2xmltest qemuxmlnstest qemuargv2xmltest \
qemumonitortest
endif
+if WITH_LXC
+TESTS += lxcxml2xmltest
+endif
+
if WITH_OPENVZ
TESTS += openvzutilstest
endif
@@ -383,6 +392,18 @@ EXTRA_DIST += qemuxml2argvtest.c qemuxml2xmltest.c qemuargv2xmltest.c \
qemumonitortest.c testutilsqemu.c testutilsqemu.h
endif
+if WITH_LXC
+
+lxc_LDADDS = ../src/libvirt_driver_lxc.la
+
+lxcxml2xmltest_SOURCES = \
+ lxcxml2xmltest.c testutilslxc.c testutilslxc.h \
+ testutils.c testutils.h
+lxcxml2xmltest_LDADD = $(lxc_LDADDS) $(LDADDS)
+else
+EXTRA_DIST += lxcxml2xmltest.c testutilslxc.c testutilslxc.h
+endif
+
if WITH_OPENVZ
openvzutilstest_SOURCES = \
openvzutilstest.c \
diff --git a/tests/lxcxml2xmldata/lxc-systemd.xml b/tests/lxcxml2xmldata/lxc-systemd.xml
new file mode 100644
index 0000000..bf239c2
--- /dev/null
+++ b/tests/lxcxml2xmldata/lxc-systemd.xml
@@ -0,0 +1,30 @@
+<domain type='lxc'>
+ <name>demo</name>
+ <uuid>8369f1ac-7e46-e869-4ca5-759d51478066</uuid>
+ <memory unit='KiB'>500000</memory>
+ <currentMemory unit='KiB'>500000</currentMemory>
+ <vcpu>1</vcpu>
+ <os>
+ <type arch='x86_64'>exe</type>
+ <init>/bin/systemd</init>
+ <initarg>--unit</initarg>
+ <initarg>emergency.service</initarg>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <filesystem type='mount' accessmode='passthrough'>
+ <source dir='/root/container'/>
+ <target dir='/'/>
+ </filesystem>
+ <filesystem type='mount' accessmode='passthrough'>
+ <source dir='/home'/>
+ <target dir='/home'/>
+ </filesystem>
+ <console type='pty'>
+ <target type='lxc' port='0'/>
+ </console>
+ </devices>
+</domain>
diff --git a/tests/lxcxml2xmltest.c b/tests/lxcxml2xmltest.c
new file mode 100644
index 0000000..558bd01
--- /dev/null
+++ b/tests/lxcxml2xmltest.c
@@ -0,0 +1,141 @@
+#include <config.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+
+#include <sys/types.h>
+#include <fcntl.h>
+
+#ifdef WITH_LXC
+
+# include "internal.h"
+# include "testutils.h"
+# include "lxc/lxc_conf.h"
+# include "testutilslxc.h"
+
+static virCapsPtr caps;
+
+static int
+testCompareXMLToXMLFiles(const char *inxml, const char *outxml, bool live)
+{
+ char *inXmlData = NULL;
+ char *outXmlData = NULL;
+ char *actual = NULL;
+ int ret = -1;
+ virDomainDefPtr def = NULL;
+
+ if (virtTestLoadFile(inxml, &inXmlData) < 0)
+ goto fail;
+ if (virtTestLoadFile(outxml, &outXmlData) < 0)
+ goto fail;
+
+ if (!(def = virDomainDefParseString(caps, inXmlData,
+ 1 << VIR_DOMAIN_VIRT_LXC,
+ live ? 0 : VIR_DOMAIN_XML_INACTIVE)))
+ goto fail;
+
+ if (!(actual = virDomainDefFormat(def, VIR_DOMAIN_XML_SECURE)))
+ goto fail;
+
+ if (STRNEQ(outXmlData, actual)) {
+ virtTestDifference(stderr, outXmlData, actual);
+ goto fail;
+ }
+
+ ret = 0;
+ fail:
+ VIR_FREE(inXmlData);
+ VIR_FREE(outXmlData);
+ VIR_FREE(actual);
+ virDomainDefFree(def);
+ return ret;
+}
+
+struct testInfo {
+ const char *name;
+ int different;
+ bool inactive_only;
+};
+
+static int
+testCompareXMLToXMLHelper(const void *data)
+{
+ const struct testInfo *info = data;
+ char *xml_in = NULL;
+ char *xml_out = NULL;
+ int ret = -1;
+
+ if (virAsprintf(&xml_in, "%s/lxcxml2xmldata/lxc-%s.xml",
+ abs_srcdir, info->name) < 0 ||
+ virAsprintf(&xml_out, "%s/lxcxml2xmloutdata/lxc-%s.xml",
+ abs_srcdir, info->name) < 0)
+ goto cleanup;
+
+ if (info->different) {
+ ret = testCompareXMLToXMLFiles(xml_in, xml_out, false);
+ } else {
+ ret = testCompareXMLToXMLFiles(xml_in, xml_in, false);
+ }
+ if (!info->inactive_only) {
+ if (info->different) {
+ ret = testCompareXMLToXMLFiles(xml_in, xml_out, true);
+ } else {
+ ret = testCompareXMLToXMLFiles(xml_in, xml_in, true);
+ }
+ }
+
+cleanup:
+ VIR_FREE(xml_in);
+ VIR_FREE(xml_out);
+ return ret;
+}
+
+
+static int
+mymain(void)
+{
+ int ret = 0;
+
+ if ((caps = testLXCCapsInit()) == NULL)
+ return (EXIT_FAILURE);
+
+# define DO_TEST_FULL(name, is_different, inactive) \
+ do { \
+ const struct testInfo info = {name, is_different, inactive}; \
+ if (virtTestRun("LXC XML-2-XML " name, \
+ 1, testCompareXMLToXMLHelper, &info) < 0) \
+ ret = -1; \
+ } while (0)
+
+# define DO_TEST(name) \
+ DO_TEST_FULL(name, 0, false)
+
+# define DO_TEST_DIFFERENT(name) \
+ DO_TEST_FULL(name, 1, false)
+
+ /* Unset or set all envvars here that are copied in lxcdBuildCommandLine
+ * using ADD_ENV_COPY, otherwise these tests may fail due to unexpected
+ * values for these envvars */
+ setenv("PATH", "/bin", 1);
+
+ DO_TEST("systemd");
+
+ virCapabilitiesFree(caps);
+
+ return (ret==0 ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+
+VIRT_TEST_MAIN(mymain)
+
+#else
+# include "testutils.h"
+
+int
+main(void)
+{
+ return EXIT_AM_SKIP;
+}
+
+#endif /* WITH_LXC */
diff --git a/tests/testutilslxc.c b/tests/testutilslxc.c
new file mode 100644
index 0000000..e6193af
--- /dev/null
+++ b/tests/testutilslxc.c
@@ -0,0 +1,63 @@
+#include <config.h>
+#ifdef WITH_LXC
+# include <stdlib.h>
+
+# include "testutilslxc.h"
+# include "testutils.h"
+# include "memory.h"
+# include "domain_conf.h"
+
+
+static int testLXCDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED)
+{
+ return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LXC;
+}
+
+
+virCapsPtr testLXCCapsInit(void) {
+ virCapsPtr caps;
+ virCapsGuestPtr guest;
+
+ if ((caps = virCapabilitiesNew("x86_64",
+ 0, 0)) == NULL)
+ return NULL;
+
+ caps->defaultConsoleTargetType = testLXCDefaultConsoleType;
+
+ if ((guest = virCapabilitiesAddGuest(caps, "exe", "i686", 32,
+ "/usr/libexec/libvirt_lxc", NULL,
+ 0, NULL)) == NULL)
+ goto error;
+
+ if (!virCapabilitiesAddGuestDomain(guest, "lxc", NULL, NULL, 0, NULL))
+ goto error;
+
+
+ if ((guest = virCapabilitiesAddGuest(caps, "exe", "x86_64", 64,
+ "/usr/libexec/libvirt_lxc", NULL,
+ 0, NULL)) == NULL)
+ goto error;
+
+ if (!virCapabilitiesAddGuestDomain(guest, "lxc", NULL, NULL, 0, NULL))
+ goto error;
+
+
+ if (virTestGetDebug()) {
+ char *caps_str;
+
+ caps_str = virCapabilitiesFormatXML(caps);
+ if (!caps_str)
+ goto error;
+
+ fprintf(stderr, "LXC driver capabilities:\n%s", caps_str);
+
+ VIR_FREE(caps_str);
+ }
+
+ return caps;
+
+error:
+ virCapabilitiesFree(caps);
+ return NULL;
+}
+#endif
diff --git a/tests/testutilslxc.h b/tests/testutilslxc.h
new file mode 100644
index 0000000..ee8056f
--- /dev/null
+++ b/tests/testutilslxc.h
@@ -0,0 +1,4 @@
+
+#include "capabilities.h"
+
+virCapsPtr testLXCCapsInit(void);
--
1.7.7.6
12 years, 8 months
[libvirt] [PATCH] Prefer to use 'qemu-system-i386' over 'qemu'
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
For i686 arch we look for the 'qemu' binary, followed by the
'qemu-system-x86_64' binary. This is not good with QEMU 1.0,
since the 'qemu' binary was renamed to 'qemu-system-i386'
and the 'qemu' name might be reused for another purpose
later.
Make sure we look for 'qemu-system-i386', then 'qemu-system-x86_64'
then the qemu-kvm binary. Only use 'qemu' as a very last resort
* src/qemu/qemu_capabilities.c: Prefer qemu-system-i386
---
src/qemu/qemu_capabilities.c | 48 ++++++++++++++++++++++++-----------------
1 files changed, 28 insertions(+), 20 deletions(-)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 0e09d6d..16d9b21 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -169,7 +169,6 @@ struct qemu_arch_info {
int wordsize;
const char *machine;
const char *binary;
- const char *altbinary;
const struct qemu_feature_flags *flags;
int nflags;
};
@@ -189,25 +188,25 @@ static const struct qemu_feature_flags const arch_info_x86_64_flags [] = {
/* The archicture tables for supported QEMU archs */
static const struct qemu_arch_info const arch_info_hvm[] = {
- { "i686", 32, NULL, "qemu",
- "qemu-system-x86_64", arch_info_i686_flags, 4 },
+ { "i686", 32, NULL, "qemu-system-i386",
+ arch_info_i686_flags, 4 },
{ "x86_64", 64, NULL, "qemu-system-x86_64",
- NULL, arch_info_x86_64_flags, 2 },
- { "arm", 32, NULL, "qemu-system-arm", NULL, NULL, 0 },
- { "microblaze", 32, NULL, "qemu-system-microblaze", NULL, NULL, 0 },
- { "microblazeel", 32, NULL, "qemu-system-microblazeel", NULL, NULL, 0 },
- { "mips", 32, NULL, "qemu-system-mips", NULL, NULL, 0 },
- { "mipsel", 32, NULL, "qemu-system-mipsel", NULL, NULL, 0 },
- { "sparc", 32, NULL, "qemu-system-sparc", NULL, NULL, 0 },
- { "ppc", 32, NULL, "qemu-system-ppc", NULL, NULL, 0 },
- { "ppc64", 64, NULL, "qemu-system-ppc64", NULL, NULL, 0 },
- { "itanium", 64, NULL, "qemu-system-ia64", NULL, NULL, 0 },
- { "s390x", 64, NULL, "qemu-system-s390x", NULL, NULL, 0 },
+ arch_info_x86_64_flags, 2 },
+ { "arm", 32, NULL, "qemu-system-arm", NULL, 0 },
+ { "microblaze", 32, NULL, "qemu-system-microblaze", NULL, 0 },
+ { "microblazeel", 32, NULL, "qemu-system-microblazeel", NULL, 0 },
+ { "mips", 32, NULL, "qemu-system-mips", NULL, 0 },
+ { "mipsel", 32, NULL, "qemu-system-mipsel", NULL, 0 },
+ { "sparc", 32, NULL, "qemu-system-sparc", NULL, 0 },
+ { "ppc", 32, NULL, "qemu-system-ppc", NULL, 0 },
+ { "ppc64", 64, NULL, "qemu-system-ppc64", NULL, 0 },
+ { "itanium", 64, NULL, "qemu-system-ia64", NULL, 0 },
+ { "s390x", 64, NULL, "qemu-system-s390x", NULL, 0 },
};
static const struct qemu_arch_info const arch_info_xen[] = {
- { "i686", 32, "xenner", "xenner", NULL, arch_info_i686_flags, 4 },
- { "x86_64", 64, "xenner", "xenner", NULL, arch_info_x86_64_flags, 2 },
+ { "i686", 32, "xenner", "xenner", arch_info_i686_flags, 4 },
+ { "x86_64", 64, "xenner", "xenner", arch_info_x86_64_flags, 2 },
};
@@ -643,10 +642,11 @@ qemuCapsInitGuest(virCapsPtr caps,
*/
binary = virFindFileInPath(info->binary);
- if (binary == NULL || !virFileIsExecutable(binary)) {
- VIR_FREE(binary);
- binary = virFindFileInPath(info->altbinary);
- }
+ /* If i386 binary is missing, we can trivially
+ * replace it with a qemu-system-x86_64 binary
+ */
+ if (binary == NULL && STREQ(info->binary, "qemu-system-i386"))
+ binary = virFindFileInPath("qemu-system-x86_64");
/* Can use acceleration for KVM/KQEMU if
* - host & guest arches match
@@ -668,6 +668,10 @@ qemuCapsInitGuest(virCapsPtr caps,
continue;
haskvm = 1;
+
+ /* We can use the KVM binary for the TCG case too
+ * (probably)
+ */
if (!binary)
binary = kvmbin;
@@ -679,6 +683,10 @@ qemuCapsInitGuest(virCapsPtr caps,
haskqemu = 1;
}
+ /* Another fallback for i386, try the old name now */
+ if (binary == NULL && STREQ(info->binary, "qemu-system-i386"))
+ binary = virFindFileInPath("qemu");
+
if (!binary)
return 0;
--
1.7.7.6
12 years, 8 months
[libvirt] Vlan ID - Portgroup
by Daniele Milani
Hi all,
I have the following problem: reading the documentation I wasn't able to understand if it is possible to associate a VlanID to a portgroup.
Does anyone know if it is possible and (more important) how does it work?
Bests,
Daniele Milani
12 years, 8 months
[libvirt] [PATCH] Detect location fo selinux mount point
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
The SELinux mount point moved from /selinux to /sys/fs/selinux
when systemd came along.
* configure.ac: Probe for SELinux mount point
* src/lxc/lxc_container.c: Use SELinux mount point determined
by configure.ac
---
configure.ac | 19 ++++++++++++++++++-
src/lxc/lxc_container.c | 6 ++++--
2 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/configure.ac b/configure.ac
index d624ef2..c1f9f45 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1238,6 +1238,10 @@ AC_ARG_WITH([selinux],
AC_HELP_STRING([--with-selinux], [use SELinux to manage security @<:@default=check@:>@]),
[],
[with_selinux=check])
+AC_ARG_WITH([selinux_mount],
+ AC_HELP_STRING([--with-selinux-mount], [set SELinux mount point @<:@default=check@:>@]),
+ [],
+ [with_selinux_mount=check])
SELINUX_CFLAGS=
SELINUX_LIBS=
@@ -1261,7 +1265,20 @@ if test "$with_selinux" != "no"; then
LIBS="$old_libs"
fi
if test "$with_selinux" = "yes"; then
+ AC_MSG_CHECKING([SELinux mount point])
+ if test "$with_selinux_mount" = "check" || test -z "$with_selinux_mount"; then
+ if test -d /sys/fs/selinux ; then
+ SELINUX_MOUNT=/sys/fs/selinux
+ else
+ SELINUX_MOUNT=/selinux
+ fi
+ else
+ SELINUX_MOUNT=$with_selinux_mount
+ fi
+ AC_MSG_RESULT([$SELINUX_MOUNT])
+
SELINUX_LIBS="-lselinux"
+ AC_DEFINE_UNQUOTED([SELINUX_MOUNT], ["$SELINUX_MOUNT"], [SELinux mount point])
AC_DEFINE_UNQUOTED([HAVE_SELINUX], 1, [whether basic SELinux functionality is available])
dnl We prefer to use <selinux/label.h> and selabel_open, but can fall
dnl back to matchpathcon for the sake of RHEL 5's version of libselinux.
@@ -2640,7 +2657,7 @@ AC_MSG_NOTICE([ Disk: $with_storage_disk])
AC_MSG_NOTICE([])
AC_MSG_NOTICE([Security Drivers])
AC_MSG_NOTICE([])
-AC_MSG_NOTICE([ SELinux: $with_secdriver_selinux])
+AC_MSG_NOTICE([ SELinux: $with_secdriver_selinux ($SELINUX_MOUNT)])
AC_MSG_NOTICE([AppArmor: $with_secdriver_apparmor])
AC_MSG_NOTICE([])
AC_MSG_NOTICE([Driver Loadable Modules])
diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index 267fbfb..bb64b60 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -444,8 +444,10 @@ static int lxcContainerMountBasicFS(const char *srcprefix, bool pivotRoot)
{ false, "/proc/sys", "/proc/sys", NULL, NULL, MS_BIND|MS_REMOUNT|MS_RDONLY },
{ true, "/sys", "/sys", NULL, NULL, MS_BIND },
{ true, "/sys", "/sys", NULL, NULL, MS_BIND|MS_REMOUNT|MS_RDONLY },
- { true, "/selinux", "/selinux", NULL, NULL, MS_BIND },
- { true, "/selinux", "/selinux", NULL, NULL, MS_BIND|MS_REMOUNT|MS_RDONLY },
+#if HAVE_SELINUX
+ { true, SELINUX_MOUNT, SELINUX_MOUNT, NULL, NULL, MS_BIND },
+ { true, SELINUX_MOUNT, SELINUX_MOUNT, NULL, NULL, MS_BIND|MS_REMOUNT|MS_RDONLY },
+#endif
};
int i, rc = -1;
char *opts = NULL;
--
1.7.7.6
12 years, 8 months