[libvirt] using disk devices with mixed bus types (ide and virtio)
by Ingo Tuchscherer
Hello,
While using multiple disk devices with different bus types (ide and virtio)
I noticed that the order of disks is handled in a special way.
The disk device which was defined as the first item will not be the first
entry in the system xml file.
e.g. if I define a virtio device (which is supposed to be the boot device)
this would be added after all the ide devices.
So it's not possible to boot from a virtio device even if I have defined
other ide devices since qemu flags the first device as boot device.
Is there a special reason why the disks are sorted by type (first all ide
and then virtio) because that's prevents from booting virtio devices.
Thanks.
Mit freundlichen Grüßen / Kind regards
Ingo Tuchscherer
14 years, 8 months
[libvirt] [PATCH] tests: test-lib.sh portability and clean-up
by Jim Meyering
No big deal, but I saw recent additions of "test ... -a ..."
(not portable) so fixed the rest, too.
Now, searching for violations shows none:
git grep '\<test .* -a '
Whether it's possible to rely on test -a in test scripts is debatable:
perhaps you've ensured that the SHELL you use when running tests is
POSIX compliant or better (I do that in coreutils), but at least in
configure.ac, we should toe the line wrt portability (because *it*
has less choice), so those are in a separate commit.
Since this is a global change, it deserves a syntax-check rule.
That's the 3/3 patch, below.
1/3 fixes test-lib.sh
2/3 fixes configure.ac
>From ca7db6cb8000cc283fcee7899140d2fc892b0296 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Wed, 24 Mar 2010 09:05:27 +0100
Subject: [PATCH 1/3] tests: shell script portability and clean-up
* tests/test-lib.sh: "echo -n" is not portable. Use printf instead.
Remove unnecessary uses of "eval-in-subshell" (subshell is sufficient).
Remove uses of tests' -a operator; it is not portable.
Instead, use "test cond && test cond2".
* tests/schematestutils.sh: Replace use of test's -a.
---
tests/schematestutils.sh | 2 +-
tests/test-lib.sh | 20 ++++++++++----------
2 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/tests/schematestutils.sh b/tests/schematestutils.sh
index 301b9eb..f172857 100644
--- a/tests/schematestutils.sh
+++ b/tests/schematestutils.sh
@@ -21,7 +21,7 @@ do
ret=$?
test_result $n $(basename $(dirname $xml))"/"$(basename $xml) $ret
- if test "$verbose" = "1" -a $ret != 0 ; then
+ if test "$verbose" = "1" && test $ret != 0 ; then
echo -e "$cmd\n$result"
fi
if test "$ret" != 0 ; then
diff --git a/tests/test-lib.sh b/tests/test-lib.sh
index 57fd438..28b830e 100644
--- a/tests/test-lib.sh
+++ b/tests/test-lib.sh
@@ -19,7 +19,7 @@ test_intro()
name=$1
if test "$verbose" = "0" ; then
echo "TEST: $name"
- echo -n " "
+ printf " "
fi
}
@@ -29,15 +29,15 @@ test_result()
name=$2
status=$3
if test "$verbose" = "0" ; then
- mod=`eval "expr \( $counter - 1 \) % 40"`
- if test "$counter" != 1 -a "$mod" = 0 ; then
- printf " %-3d\n" `eval "expr $counter - 1"`
- echo -n " "
+ mod=`expr \( $counter + 40 - 1 \) % 40`
+ if test "$counter" != 1 && test "$mod" = 0 ; then
+ printf " %-3d\n" `expr $counter - 1`
+ printf " "
fi
if test "$status" = "0" ; then
- echo -n "."
+ printf "."
else
- echo -n "!"
+ printf "!"
fi
else
if test "$status" = "0" ; then
@@ -54,11 +54,11 @@ test_final()
status=$2
if test "$verbose" = "0" ; then
- mod=`eval "expr \( $counter + 1 \) % 40"`
- if test "$mod" != "0" -a "$mod" != "1" ; then
+ mod=`expr \( $counter + 1 \) % 40`
+ if test "$mod" != "0" && test "$mod" != "1" ; then
for i in `seq $mod 40`
do
- echo -n " "
+ printf " "
done
fi
if test "$status" = "0" ; then
--
1.7.0.3.435.g097f4
>From 7998714d60b997357bfea15d6f2d0f729fc8fb29 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Wed, 24 Mar 2010 09:10:13 +0100
Subject: [PATCH 2/3] build: don't use "test cond1 -a cond2" in configure: it's not portable
* configure.ac: Use "test cond1 && test cond2" instead.
---
configure.ac | 26 +++++++++++++-------------
1 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/configure.ac b/configure.ac
index bcf1d5a..2e6d2e4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -197,10 +197,10 @@ dnl if --prefix is /usr, don't use /usr/var for localstatedir
dnl or /usr/etc for sysconfdir
dnl as this makes a lot of things break in testing situations
-if test "$prefix" = "/usr" -a "$localstatedir" = '${prefix}/var' ; then
+if test "$prefix" = "/usr" && test "$localstatedir" = '${prefix}/var' ; then
localstatedir='/var'
fi
-if test "$prefix" = "/usr" -a "$sysconfdir" = '${prefix}/etc' ; then
+if test "$prefix" = "/usr" && test "$sysconfdir" = '${prefix}/etc' ; then
sysconfdir='/etc'
fi
@@ -240,7 +240,7 @@ AC_ARG_WITH([libvirtd],
dnl
dnl specific tests to setup DV devel environments with debug etc ...
dnl
-if [[ "${LOGNAME}" = "veillard" -a "`pwd`" = "/u/veillard/libvirt" ]] ; then
+if [[ "${LOGNAME}" = "veillard" && test "`pwd`" = "/u/veillard/libvirt" ]] ; then
STATIC_BINARIES="-static"
else
STATIC_BINARIES=
@@ -351,7 +351,7 @@ LIBXENSERVER_LIBS=""
LIBXENSERVER_CFLAGS=""
dnl search for the XenServer library
if test "$with_xenapi" != "no" ; then
- if test "$with_xenapi" != "yes" -a "$with_xenapi" != "check" ; then
+ if test "$with_xenapi" != "yes" && test "$with_xenapi" != "check" ; then
LIBXENSERVER_CFLAGS="-I$with_xenapi/include"
LIBXENSERVER_LIBS="-L$with_xenapi"
fi
@@ -390,7 +390,7 @@ XEN_LIBS=""
XEN_CFLAGS=""
dnl search for the Xen store library
if test "$with_xen" != "no" ; then
- if test "$with_xen" != "yes" -a "$with_xen" != "check" ; then
+ if test "$with_xen" != "yes" && test "$with_xen" != "check" ; then
XEN_CFLAGS="-I$with_xen/include"
XEN_LIBS="-L$with_xen/lib64 -L$with_xen/lib"
fi
@@ -571,7 +571,7 @@ AC_ARG_WITH([libxml], AC_HELP_STRING([--with-libxml=@<:@PFX@:>@], [libxml2 locat
if test "x$with_libxml" = "xno" ; then
AC_MSG_CHECKING(for libxml2 libraries >= $LIBXML_REQUIRED)
AC_MSG_ERROR([libxml2 >= $LIBXML_REQUIRED is required for libvirt])
-elif test "x$with_libxml" = "x" -a "x$PKG_CONFIG" != "x" ; then
+elif test "x$with_libxml" = "x" && test "x$PKG_CONFIG" != "x" ; then
PKG_CHECK_MODULES(LIBXML, libxml-2.0 >= $LIBXML_REQUIRED, [LIBXML_FOUND=yes], [LIBXML_FOUND=no])
fi
if test "$LIBXML_FOUND" = "no" ; then
@@ -661,7 +661,7 @@ AC_ARG_WITH([sasl],
SASL_CFLAGS=
SASL_LIBS=
if test "x$with_sasl" != "xno"; then
- if test "x$with_sasl" != "xyes" -a "x$with_sasl" != "xcheck"; then
+ if test "x$with_sasl" != "xyes" && test "x$with_sasl" != "xcheck"; then
SASL_CFLAGS="-I$with_sasl"
SASL_LIBS="-L$with_sasl"
fi
@@ -716,7 +716,7 @@ AC_ARG_WITH([yajl],
YAJL_CFLAGS=
YAJL_LIBS=
if test "x$with_yajl" != "xno"; then
- if test "x$with_yajl" != "xyes" -a "x$with_yajl" != "xcheck"; then
+ if test "x$with_yajl" != "xyes" && test "x$with_yajl" != "xcheck"; then
YAJL_CFLAGS="-I$with_yajl/include"
YAJL_LIBS="-L$with_yajl/lib"
fi
@@ -1004,7 +1004,7 @@ AC_ARG_WITH([numactl],
NUMACTL_CFLAGS=
NUMACTL_LIBS=
-if test "$with_qemu" = "yes" -a "$with_numactl" != "no"; then
+if test "$with_qemu" = "yes" && test "$with_numactl" != "no"; then
old_cflags="$CFLAGS"
old_libs="$LIBS"
if test "$with_numactl" = "check"; then
@@ -1062,7 +1062,7 @@ dnl
dnl libssh checks
dnl
-if test "$with_libssh2" != "yes" -a "$with_libssh2" != "no"; then
+if test "$with_libssh2" != "yes" && test "$with_libssh2" != "no"; then
libssh2_path="$with_libssh2"
elif test "$with_libssh2" = "yes"; then
libssh2_path="/usr/local/lib/"
@@ -1143,7 +1143,7 @@ dnl introduced in 0.4.0 release which need as minimum
dnl
CAPNG_CFLAGS=
CAPNG_LIBS=
-if test "$with_qemu" = "yes" -a "$with_capng" != "no"; then
+if test "$with_qemu" = "yes" && test "$with_capng" != "no"; then
old_cflags="$CFLAGS"
old_libs="$LIBS"
if test "$with_capng" = "check"; then
@@ -1453,7 +1453,7 @@ if test "$with_storage_disk" = "yes" -o "$with_storage_disk" = "check"; then
PARTED_FOUND=yes
fi
- if test "$with_storage_disk" != "no" -a "x$PKG_CONFIG" != "x" ; then
+ if test "$with_storage_disk" != "no" && test "x$PKG_CONFIG" != "x" ; then
PKG_CHECK_MODULES(LIBPARTED, libparted >= $PARTED_REQUIRED, [], [PARTED_FOUND=no])
fi
if test "$PARTED_FOUND" = "no"; then
@@ -1635,7 +1635,7 @@ else
fi
AC_MSG_RESULT($RUNNING_XEND)
-AM_CONDITIONAL([ENABLE_XEN_TESTS], [test "$RUNNING_XEN" != "no" -a "$RUNNING_XEND" != "no"])
+AM_CONDITIONAL([ENABLE_XEN_TESTS], [test "$RUNNING_XEN" != "no" && test "$RUNNING_XEND" != "no"])
AC_ARG_ENABLE([test-coverage],
AC_HELP_STRING([--enable-test-coverage], [turn on code coverage instrumentation @<:@default=no@:>@]),
--
1.7.0.3.435.g097f4
>From 95c8ddd2eca90e3024a6f74af84517c1e0115a60 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Wed, 24 Mar 2010 09:32:43 +0100
Subject: [PATCH 3/3] maint: add syntax-check rule to prohibit use of test's -a operator
* cfg.mk (sc_prohibit_test_minus_a): New rule.
---
cfg.mk | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/cfg.mk b/cfg.mk
index 2d0d278..4302338 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -269,6 +269,12 @@ sc_preprocessor_indentation:
echo '$(ME): skipping test $@: cppi not installed' 1>&2; \
fi
+# Using test's -a operator is not portable.
+sc_prohibit_test_minus_a:
+ @re='\<test .+ -[a] ' \
+ msg='use "test C1 && test C2, not "test C1 -''a C2"' \
+ $(_prohibit_regexp)
+
sc_copyright_format:
@$(VC_LIST_EXCEPT) | xargs grep -ni 'copyright .*Red 'Hat \
| grep -v Inc \
--
1.7.0.3.435.g097f4
14 years, 8 months
[libvirt] Supporting hypervisor specific APIs in libvirt
by Anthony Liguori
Hi,
I've mentioned this to a few folks already but I wanted to start a
proper thread.
We're struggling in qemu with usability and one area that concerns me is
the disparity in features that are supported by qemu vs what's
implemented in libvirt.
This isn't necessarily libvirt's problem if it's mission is to provide a
common hypervisor API that covers the most commonly used features.
However, for qemu, we need an API that covers all of our features that
people can develop against. The ultimate question we need to figure out
is, should we encourage our users to always use libvirt or should we
build our own API for people (and libvirt) to consume.
I don't think it's necessarily a big technical challenge for libvirt to
support qemu more completely. I think it amounts to introducing a
series of virQemuXXXX APIs that implement qemu specific functions. Over
time, qemu specific APIs can be deprecated in favour of more generic
virDomain APIs.
What's the feeling about this from the libvirt side of things? Is there
interest in support hypervisor specific interfaces should we be looking
to provide our own management interface for libvirt to consume?
Regards,
Anthony Liguori
14 years, 8 months
[libvirt] [PATCH] esx: Make the conf parser compare names case insensitive in VMX mode
by Matthias Bolte
The keys of entries in a VMX file are case insensitive. Both scsi0:1.fileName
and scsi0:1.filename are valid. Therefore, make the conf parser compare names
case insensitive in VMX mode to accept every capitalization variation.
Also add test cases for this.
---
src/util/conf.c | 5 ++-
tests/vmx2xmldata/vmx2xml-case-insensitive-1.vmx | 51 ++++++++++++++++++++++
tests/vmx2xmldata/vmx2xml-case-insensitive-1.xml | 25 +++++++++++
tests/vmx2xmldata/vmx2xml-case-insensitive-2.vmx | 51 ++++++++++++++++++++++
tests/vmx2xmldata/vmx2xml-case-insensitive-2.xml | 25 +++++++++++
tests/vmx2xmltest.c | 9 ++++
6 files changed, 165 insertions(+), 1 deletions(-)
create mode 100644 tests/vmx2xmldata/vmx2xml-case-insensitive-1.vmx
create mode 100644 tests/vmx2xmldata/vmx2xml-case-insensitive-1.xml
create mode 100644 tests/vmx2xmldata/vmx2xml-case-insensitive-2.vmx
create mode 100644 tests/vmx2xmldata/vmx2xml-case-insensitive-2.xml
diff --git a/src/util/conf.c b/src/util/conf.c
index 24588c2..ae0459e 100644
--- a/src/util/conf.c
+++ b/src/util/conf.c
@@ -831,7 +831,10 @@ virConfGetValue(virConfPtr conf, const char *setting)
cur = conf->entries;
while (cur != NULL) {
- if ((cur->name != NULL) && (STREQ(cur->name, setting)))
+ if ((cur->name != NULL) &&
+ ((conf->flags & VIR_CONF_FLAG_VMX_FORMAT &&
+ STRCASEEQ(cur->name, setting)) ||
+ STREQ(cur->name, setting)))
return(cur->value);
cur = cur->next;
}
diff --git a/tests/vmx2xmldata/vmx2xml-case-insensitive-1.vmx b/tests/vmx2xmldata/vmx2xml-case-insensitive-1.vmx
new file mode 100644
index 0000000..3626c5e
--- /dev/null
+++ b/tests/vmx2xmldata/vmx2xml-case-insensitive-1.vmx
@@ -0,0 +1,51 @@
+CONFIG.VERSION = "8"
+VIRTUALHW.VERSION = "4"
+FLOPPY0.PRESENT = "FALSE"
+NVRAM = "FEDORA11.NVRAM"
+DEPLOYMENTPLATFORM = "WINDOWS"
+VIRTUALHW.PRODUCTCOMPATIBILITY = "HOSTED"
+TOOLS.UPGRADE.POLICY = "USEGLOBAL"
+POWERTYPE.POWEROFF = "DEFAULT"
+POWERTYPE.POWERON = "DEFAULT"
+POWERTYPE.SUSPEND = "DEFAULT"
+POWERTYPE.RESET = "DEFAULT"
+
+DISPLAYNAME = "FEDORA11"
+EXTENDEDCONFIGFILE = "FEDORA11.VMXF"
+
+SCSI0.PRESENT = "TRUE"
+SCSI0.SHAREDBUS = "NONE"
+SCSI0.VIRTUALDEV = "LSILOGIC"
+MEMSIZE = "1024"
+SCSI0:0.PRESENT = "TRUE"
+SCSI0:0.FILENAME = "FEDORA11.vmdk"
+SCSI0:0.DEVICETYPE = "SCSI-HARDDISK"
+IDE0:0.PRESENT = "TRUE"
+IDE0:0.CLIENTDEVICE = "TRUE"
+IDE0:0.DEVICETYPE = "CDROM-RAW"
+IDE0:0.STARTCONNECTED = "FALSE"
+ETHERNET0.PRESENT = "TRUE"
+ETHERNET0.NETWORKNAME = "VM NETWORK"
+ETHERNET0.ADDRESSTYPE = "VPX"
+ETHERNET0.GENERATEDADDRESS = "00:50:56:91:48:C7"
+CHIPSET.ONLINESTANDBY = "FALSE"
+GUESTOSALTNAME = "RED HAT ENTERPRISE LINUX 5 (32-BIT)"
+GUESTOS = "RHEL5"
+UUID.BIOS = "50 11 5E 16 9B DC 49 D7-F1 71 53 C4 D7 F9 17 10"
+SNAPSHOT.ACTION = "KEEP"
+SCHED.CPU.MIN = "0"
+SCHED.CPU.UNITS = "MHZ"
+SCHED.CPU.SHARES = "NORMAL"
+SCHED.MEM.MINSIZE = "0"
+SCHED.MEM.SHARES = "NORMAL"
+TOOLSCRIPTS.AFTERPOWERON = "TRUE"
+TOOLSCRIPTS.AFTERRESUME = "TRUE"
+TOOLSCRIPTS.BEFORESUSPEND = "TRUE"
+TOOLSCRIPTS.BEFOREPOWEROFF = "TRUE"
+
+SCSI0:0.REDO = ""
+TOOLS.SYNCTIME = "FALSE"
+UUID.LOCATION = "56 4D B5 06 A2 BD FB EB-AE 86 F7 D8 49 27 D0 C4"
+SCHED.CPU.MAX = "UNLIMITED"
+SCHED.SWAP.DERIVEDNAME = "/VMFS/VOLUMES/498076B2-02796C1A-EF5B-000AE484A6A3/FEDORA11/FEDORA11-7DE040D8.VSWP"
+TOOLS.REMINDINSTALL = "TRUE"
diff --git a/tests/vmx2xmldata/vmx2xml-case-insensitive-1.xml b/tests/vmx2xmldata/vmx2xml-case-insensitive-1.xml
new file mode 100644
index 0000000..0be570f
--- /dev/null
+++ b/tests/vmx2xmldata/vmx2xml-case-insensitive-1.xml
@@ -0,0 +1,25 @@
+<domain type='vmware'>
+ <name>FEDORA11</name>
+ <uuid>50115e16-9bdc-49d7-f171-53c4d7f91710</uuid>
+ <memory>1048576</memory>
+ <currentMemory>1048576</currentMemory>
+ <vcpu>1</vcpu>
+ <os>
+ <type arch='i686'>hvm</type>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <disk type='file' device='disk'>
+ <driver name='LSILOGIC'/>
+ <source file='[datastore] directory/FEDORA11.vmdk'/>
+ <target dev='sda' bus='scsi'/>
+ </disk>
+ <interface type='bridge'>
+ <mac address='00:50:56:91:48:c7'/>
+ <source bridge='VM NETWORK'/>
+ </interface>
+ </devices>
+</domain>
diff --git a/tests/vmx2xmldata/vmx2xml-case-insensitive-2.vmx b/tests/vmx2xmldata/vmx2xml-case-insensitive-2.vmx
new file mode 100644
index 0000000..a485d03
--- /dev/null
+++ b/tests/vmx2xmldata/vmx2xml-case-insensitive-2.vmx
@@ -0,0 +1,51 @@
+config.version = "8"
+virtualhw.version = "4"
+floppy0.present = "false"
+nvram = "fedora11.nvram"
+deploymentplatform = "windows"
+virtualhw.productcompatibility = "hosted"
+tools.upgrade.policy = "useglobal"
+powertype.poweroff = "default"
+powertype.poweron = "default"
+powertype.suspend = "default"
+powertype.reset = "default"
+
+displayname = "fedora11"
+extendedconfigfile = "fedora11.vmxf"
+
+scsi0.present = "true"
+scsi0.sharedbus = "none"
+scsi0.virtualdev = "lsilogic"
+memsize = "1024"
+scsi0:0.present = "true"
+scsi0:0.filename = "fedora11.vmdk"
+scsi0:0.devicetype = "scsi-harddisk"
+ide0:0.present = "true"
+ide0:0.clientdevice = "true"
+ide0:0.devicetype = "cdrom-raw"
+ide0:0.startconnected = "false"
+ethernet0.present = "true"
+ethernet0.networkname = "vm network"
+ethernet0.addresstype = "vpx"
+ethernet0.generatedaddress = "00:50:56:91:48:c7"
+chipset.onlinestandby = "false"
+guestosaltname = "red hat enterprise linux 5 (32-bit)"
+guestos = "rhel5"
+uuid.bios = "50 11 5e 16 9b dc 49 d7-f1 71 53 c4 d7 f9 17 10"
+snapshot.action = "keep"
+sched.cpu.min = "0"
+sched.cpu.units = "mhz"
+sched.cpu.shares = "normal"
+sched.mem.minsize = "0"
+sched.mem.shares = "normal"
+toolscripts.afterpoweron = "true"
+toolscripts.afterresume = "true"
+toolscripts.beforesuspend = "true"
+toolscripts.beforepoweroff = "true"
+
+scsi0:0.redo = ""
+tools.synctime = "false"
+uuid.location = "56 4d b5 06 a2 bd fb eb-ae 86 f7 d8 49 27 d0 c4"
+sched.cpu.max = "unlimited"
+sched.swap.derivedname = "/vmfs/volumes/498076b2-02796c1a-ef5b-000ae484a6a3/fedora11/fedora11-7de040d8.vswp"
+tools.remindinstall = "true"
diff --git a/tests/vmx2xmldata/vmx2xml-case-insensitive-2.xml b/tests/vmx2xmldata/vmx2xml-case-insensitive-2.xml
new file mode 100644
index 0000000..766172f
--- /dev/null
+++ b/tests/vmx2xmldata/vmx2xml-case-insensitive-2.xml
@@ -0,0 +1,25 @@
+<domain type='vmware'>
+ <name>fedora11</name>
+ <uuid>50115e16-9bdc-49d7-f171-53c4d7f91710</uuid>
+ <memory>1048576</memory>
+ <currentMemory>1048576</currentMemory>
+ <vcpu>1</vcpu>
+ <os>
+ <type arch='i686'>hvm</type>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <disk type='file' device='disk'>
+ <driver name='lsilogic'/>
+ <source file='[datastore] directory/fedora11.vmdk'/>
+ <target dev='sda' bus='scsi'/>
+ </disk>
+ <interface type='bridge'>
+ <mac address='00:50:56:91:48:c7'/>
+ <source bridge='vm network'/>
+ </interface>
+ </devices>
+</domain>
diff --git a/tests/vmx2xmltest.c b/tests/vmx2xmltest.c
index b4eb5d5..4c93059 100644
--- a/tests/vmx2xmltest.c
+++ b/tests/vmx2xmltest.c
@@ -26,6 +26,7 @@ testCompareFiles(const char *vmx, const char *xml, esxVI_APIVersion apiVersion)
char *vmxPtr = &(vmxData[0]);
char *xmlPtr = &(xmlData[0]);
virDomainDefPtr def = NULL;
+ virErrorPtr err = NULL;
if (virtTestLoadFile(vmx, &vmxPtr, MAX_FILE) < 0) {
goto failure;
@@ -39,12 +40,16 @@ testCompareFiles(const char *vmx, const char *xml, esxVI_APIVersion apiVersion)
apiVersion);
if (def == NULL) {
+ err = virGetLastError();
+ fprintf(stderr, "ERROR: %s\n", err != NULL ? err->message : "<unknown>");
goto failure;
}
formatted = virDomainDefFormat(def, VIR_DOMAIN_XML_SECURE);
if (formatted == NULL) {
+ err = virGetLastError();
+ fprintf(stderr, "ERROR: %s\n", err != NULL ? err->message : "<unknown>");
goto failure;
}
@@ -117,6 +122,10 @@ mymain(int argc, char **argv)
} \
} while (0)
+
+ DO_TEST("case-insensitive-1", "case-insensitive-1", esxVI_APIVersion_25);
+ DO_TEST("case-insensitive-2", "case-insensitive-2", esxVI_APIVersion_25);
+
DO_TEST("minimal", "minimal", esxVI_APIVersion_25);
DO_TEST("minimal-64bit", "minimal-64bit", esxVI_APIVersion_25);
--
1.6.3.3
14 years, 8 months
[libvirt] [PATCH v3 00/14] Network filtering (ACL) extensions for libvirt
by stefanb@us.ibm.com
Hi!
This is a repost of this set of patches with some of the suggested fixes applied and ipv6 support on the ebtables layer added.
The following set of patches add network filtering (ACL) extensions to
libvirt and enable network traffic filtering for VMs using ebtables and,
depending on the networking technology being used (tap, but not
macvtap), also iptables. Usage of either is optional and controlled
through filters that a VM is referencing.
The ebtables-level filtering is based on the XML derived from the CIM
network slide 10 (filtering) from the DMTF website
(http://www.dmtf.org/standards/cim/cim_schema_v2230/CIM_Network.pdf).
The XML we derived from this was discussed on the list before. On the
ebtables level we currently handle filtering of IPv4 and ARP traffic.
The iptables-level filtering is based on similar XML where XML nodes
described the particular protocol to filter for. Its extensions enable
the filtering of traffic using iptables for tcp, udp, icmp, igmp, sctp
and 'all' types of traffic. This list of protocols maps to the features
supported by iptables and only excludes protocols like 'esp', 'ah' and
'udplite'. Currently only bridging mode is supported and based on
availability of the physdev match.
The filtering framework adds new libvirt virsh commands for managing
the filters. The 5 new commands are:
- virsh nwfilter-list
- virsh nwfilter-dumpxml <name of filter>
- virsh nwfilter-define <name of file containing filter desc.>
- virsh nwfilter-undefine <name of filter>
- virsh nwfilter-edit <name of filter>
Above commands are similar to commands for already existing pools and as
such much of the code directly related to the above commands could be
borrowed from other drivers.
The network filters can either contain rules using the above mentioned
XML or contain references to other filters in order to build more
complex filters that form some sort of filter tree or can contain both.
An example for a filter referencing other filters would be this one
here:
<filter name='demofilter4' chain='root'>
<uuid>66f62d1d-34c1-1421-824f-c62d5ee5e8b6</uuid>
<filterref filter='no-mac-spoofing'/>
<filterref filter='no-mac-broadcast'/>
<filterref filter='no-arp-spoofing'/>
<filterref filter='allow-dhcp'>
<parameter name='DHCPSERVER' value='10.0.0.1'/>
</filterref>
<filterref filter='no-other-l2-traffic'/>
<filterref filter='recv-only-vm-ipaddress'/>
<filterref filter='recv-only-vm-macaddress'/>
<filterref filter='l3-test'/>
<filterref filter='ipv6test'/>
</filter>
A filter containing actual rules would look like this:
<filter name='no-mac-broadcast' chain='ipv4'>
<uuid>ffe2ccd6-edec-7360-1852-6b5ccb553234</uuid>
<rule action='drop' direction='out' priority='500'>
<mac dstmacaddr='ff:ff:ff:ff:ff:ff'/>
</rule>
</filter>
The filter XML now also holds a priority attribute in the rule. This
provides control over the ordering of the applied ebtables/iptables
rules beyond their appearance in the XML.
The domain XML has been extended to reference a top level filter from
within each <interface> XML node. A valid reference to such a top level
filter looks like this:
<interface type='bridge'>
<source bridge='static'/>
<filterref filter='demofilter4'>
<parameter name='IP' value='9.59.241.151'/>
</filterref>
</interface>
In this XML a parameter IP is passed for instantiation of the referenced
filters, that may require the availability of this parameter. In the
above case the IP parameter's value describes the value of the IP
address of the VM and allows to enable those filters to be instantiated
that require this 'IP' variable. If a filter requires a parameter that
is not provided, the VM will not start or the interface will not attach
to a running VM. Any names of parameters can be provided for
instantiation of filters and their names and values only need to pass a
regular expression test. In a subsequent patch we will be adding
capability to allow users to omit the IP parameter (only) and enable
libvirt to learn the IP address of the VM and have it instantiate the
filter once it knows it.
While virtual machines are running, it is possible to update their
filters. For that all running VMs' filter 'trees' are traversed to
detect whether the updated filter is referenced by the VM. If so, its
ebtables/iptable rules are applied. If one of the VMs' update fails
allupdates are rolled back and the filter XML update is rejected.
One comment about the instantiation of the rules: Since the XML allows
to create nearly any possible combination of parameters to ebtables or
iptables commands, I haven't used the ebtables or iptables wrappers.
Instead, I am writing ebtables/iptables command into a buffer, add
command line options to each one of them as described in the rule's XML,
write the buffer into a file and run it as a script. For those commands
that are not allowed to fail I am using the following format to run
them:
cmd="ebtables <some options>"
r=`${cmd}`
if [ $? -ne 0 ]; then
echo "Failure in command ${cmd}."
exit 1
fi
cmd="..."
[...]
If one of the command fails in such a batch, the libvirt code is going
pick up the error code '1', tear down anything previously established
and report an error back. The actual error message shown above is
currently not reported back, but can be later on with some changes to
the commands running external programs that need to read the script's
stdout.
One comment to patch 14: It currently #include's a .c file into a .c
file only for the reason so I don't have to change too much code once I
change code in the underlying patch. So this has to be changed. The
patch series works without patch 13, but then only supports ebtables.
The patches apply to the current tip. They pass 'make syntax-check' and
have been frequently run in valgrind for memory leak checks.
Looking forward to your feedback on the patches.
Thanks and regards,
Stefan and Gerhard
14 years, 8 months
[libvirt] [PATCH][QEMU driver] Catch cdrom change error
by Ryan Harper
Currently when we attempt to change the cdrom in a qemu VM the monitor
doesn't generate an error if the target filename doesn't exist. I've
submitted a patch[1] for this. This patch is the libvirt qemu-driver
side which catches the error message from the monitor and reportes the
error to libvirt. This means that virsh attach-disk cdrom commands
won't appear to succeed when qemu change command actually failed.
I've tested this patch on an older libvirt (rebuild libvirt-0.7.0 on my
ubuntu host) but haven't rebuilt against git head since I can't
quite compile that on my host.
1. http://lists.gnu.org/archive/html/qemu-devel/2010-03/msg01935.html
Signed-off-by: Ryan Harper <ryanh(a)us.ibm.com>
diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c
index 1596e59..f868907 100644
--- a/src/qemu/qemu_monitor_text.c
+++ b/src/qemu/qemu_monitor_text.c
@@ -905,7 +905,14 @@ int qemuMonitorTextChangeMedia(qemuMonitorPtr mon,
qemuReportError(VIR_ERR_OPERATION_FAILED,
_("could not eject media on %s: %s"), devname, reply);
goto cleanup;
- }
+ }
+
+ /* Could not open message indicates bad filename */
+ if (strstr(reply, "\nCould not open ")) {
+ qemuReportError(VIR_ERR_OPERATION_FAILED,
+ _("could not change media on %s: %s"), devname, reply);
+ goto cleanup;
+ }
ret = 0;
--
Ryan Harper
Software Engineer; Linux Technology Center
IBM Corp., Austin, Tx
ryanh(a)us.ibm.com
14 years, 8 months
[libvirt] [PATCH 00/13] Add support for all QEMU event notifications
by Daniel P. Berrange
This series adds support for (nearly) all QEMU event notifications
that are currently supported by the new JSON mode monitor.
- Guest reboot
- RTC adjustment
- Watchdog firing
- Block IO errors
- Graphics client connect/disconnect
It required two new public APIs, and a bunch of extra function
callback typedefs which will be shown in each following commit
message.
This scheme is extensible to support any further events against
domains.
It does not support events on other types of object (storage,
node devices, etc), but those can follow exactly the same API
design scheme should we need them in the future. We don't want
to unify them at the public API level, since internally they
need to dispatch to separate drivers anyway.
I'm generally happy with the public API for the events, with
the exception of the graphics event which is horribly complex
due to the large amount of data. I'm not sure if there's a way
to make that event nicer....
The full diffstat for all patches
daemon/dispatch.h | 10
daemon/libvirtd.c | 20
daemon/libvirtd.h | 2
daemon/remote.c | 348 ++++++++++++++--
daemon/remote_dispatch_args.h | 2
daemon/remote_dispatch_prototypes.h | 16
daemon/remote_dispatch_table.h | 37 +
examples/domain-events/events-c/event-test.c | 168 ++++++-
include/libvirt/libvirt.h.in | 106 ++++
src/conf/domain_event.c | 580 ++++++++++++++++++++++++---
src/conf/domain_event.h | 82 +++
src/driver.c | 4
src/driver.h | 18
src/esx/esx_driver.c | 2
src/libvirt.c | 133 +++++-
src/libvirt_private.syms | 16
src/libvirt_public.syms | 6
src/lxc/lxc_driver.c | 60 ++
src/opennebula/one_driver.c | 2
src/openvz/openvz_driver.c | 2
src/phyp/phyp_driver.c | 2
src/qemu/qemu_driver.c | 290 +++++++++++++
src/qemu/qemu_monitor.c | 77 +++
src/qemu/qemu_monitor.h | 39 +
src/qemu/qemu_monitor_json.c | 144 ++++++
src/remote/remote_driver.c | 459 +++++++++++++++++----
src/remote/remote_protocol.c | 111 +++++
src/remote/remote_protocol.h | 185 ++++++--
src/remote/remote_protocol.x | 65 ++-
src/test/test_driver.c | 58 ++
src/uml/uml_driver.c | 2
src/vbox/vbox_tmpl.c | 155 +++++--
src/xen/xen_driver.c | 71 ++-
src/xenapi/xenapi_driver.c | 2
34 files changed, 2947 insertions(+), 327 deletions(-)
Daniel
14 years, 8 months
[libvirt] [PATCH 0/1] Disk error policy
by David Allan
The following patch adds support for setting the disk error policy to the domain XML and using it when setting up the qemu command line. It specifies the werror=somepolicy,rerror=somepolicy flags to tell qemu what to do in the case of an io error. This patch is my first foray into the setup of the qemu command line, so please review with heightened care.
Dave
David Allan (1):
Add disk error policy to domain XML
docs/schemas/domain.rng | 12 +++++++++++-
src/conf/domain_conf.c | 15 +++++++++++++++
src/conf/domain_conf.h | 10 ++++++++++
src/libvirt_private.syms | 2 +-
src/qemu/qemu_conf.c | 12 +++++++++---
tests/qemuhelptest.c | 1 +
tests/qemuxml2argvtest.c | 3 +++
7 files changed, 50 insertions(+), 5 deletions(-)
14 years, 8 months
[libvirt] [PATCH] Add entry point logging for cpu functions
by Jiri Denemark
---
src/cpu/cpu.c | 46 ++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 44 insertions(+), 2 deletions(-)
diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c
index be0f15e..183862a 100644
--- a/src/cpu/cpu.c
+++ b/src/cpu/cpu.c
@@ -23,6 +23,7 @@
#include <config.h>
+#include "logging.h"
#include "memory.h"
#include "xml.h"
#include "cpu.h"
@@ -73,6 +74,8 @@ cpuCompareXML(virCPUDefPtr host,
virCPUDefPtr cpu = NULL;
virCPUCompareResult ret = VIR_CPU_COMPARE_ERROR;
+ VIR_DEBUG("host=%p, xml=%s", host, NULLSTR(xml));
+
if (!(doc = virXMLParseString(xml, "cpu.xml")))
goto cleanup;
@@ -104,6 +107,8 @@ cpuCompare(virCPUDefPtr host,
{
struct cpuArchDriver *driver;
+ VIR_DEBUG("host=%p, cpu=%p", host, cpu);
+
if ((driver = cpuGetSubDriver(host->arch)) == NULL)
return VIR_CPU_COMPARE_ERROR;
@@ -126,6 +131,13 @@ cpuDecode(virCPUDefPtr cpu,
{
struct cpuArchDriver *driver;
+ VIR_DEBUG("cpu=%p, data=%p, nmodels=%u", cpu, data, nmodels);
+ if (models) {
+ unsigned int i;
+ for (i = 0; i < nmodels; i++)
+ VIR_DEBUG("models[%u]=%s", i, NULLSTR(models[i]));
+ }
+
if (models == NULL && nmodels != 0) {
virCPUReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("nonzero nmodels doesn't match with NULL models"));
@@ -163,6 +175,11 @@ cpuEncode(const char *arch,
{
struct cpuArchDriver *driver;
+ VIR_DEBUG("arch=%s, cpu=%p, forced=%p, required=%p, "
+ "optional=%p, disabled=%p, forbidden=%p",
+ NULLSTR(arch), cpu, forced, required,
+ optional, disabled, forbidden);
+
if ((driver = cpuGetSubDriver(arch)) == NULL)
return -1;
@@ -184,6 +201,8 @@ cpuDataFree(const char *arch,
{
struct cpuArchDriver *driver;
+ VIR_DEBUG("arch=%s, data=%p", NULLSTR(arch), data);
+
if (data == NULL)
return;
@@ -206,6 +225,8 @@ cpuNodeData(const char *arch)
{
struct cpuArchDriver *driver;
+ VIR_DEBUG("arch=%s", NULLSTR(arch));
+
if ((driver = cpuGetSubDriver(arch)) == NULL)
return NULL;
@@ -227,6 +248,8 @@ cpuGuestData(virCPUDefPtr host,
{
struct cpuArchDriver *driver;
+ VIR_DEBUG("host=%p, guest=%p, data=%p", host, guest, data);
+
if ((driver = cpuGetSubDriver(host->arch)) == NULL)
return VIR_CPU_COMPARE_ERROR;
@@ -254,6 +277,16 @@ cpuBaselineXML(const char **xmlCPUs,
char *cpustr;
unsigned int i;
+ VIR_DEBUG("ncpus=%u, nmodels=%u", ncpus, nmodels);
+ if (xmlCPUs) {
+ for (i = 0; i < ncpus; i++)
+ VIR_DEBUG("xmlCPUs[%u]=%s", i, NULLSTR(xmlCPUs[i]));
+ }
+ if (models) {
+ for (i = 0; i < nmodels; i++)
+ VIR_DEBUG("models[%u]=%s", i, NULLSTR(models[i]));
+ }
+
if (xmlCPUs == NULL && ncpus != 0) {
virCPUReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("nonzero ncpus doesn't match with NULL xmlCPUs"));
@@ -320,6 +353,17 @@ cpuBaseline(virCPUDefPtr *cpus,
{
struct cpuArchDriver *driver;
virCPUDefPtr cpu;
+ unsigned int i;
+
+ VIR_DEBUG("ncpus=%u, nmodels=%u", ncpus, nmodels);
+ if (cpus) {
+ for (i = 0; i < ncpus; i++)
+ VIR_DEBUG("cpus[%u]=%p", i, cpus[i]);
+ }
+ if (models) {
+ for (i = 0; i < nmodels; i++)
+ VIR_DEBUG("models[%u]=%s", i, NULLSTR(models[i]));
+ }
if (cpus == NULL && ncpus != 0) {
virCPUReportError(VIR_ERR_INTERNAL_ERROR,
@@ -349,8 +393,6 @@ cpuBaseline(virCPUDefPtr *cpus,
}
if ((cpu = driver->baseline(cpus, ncpus, models, nmodels))) {
- int i;
-
cpu->type = VIR_CPU_TYPE_GUEST;
cpu->match = VIR_CPU_MATCH_EXACT;
VIR_FREE(cpu->arch);
--
1.7.0.3
14 years, 8 months
[libvirt] Sleeping 50 microseconds in qemuDomainWaitForMigrationComplete?
by Matthias Bolte
There is this nanosleep call in the QEMU driver.
/* Poll every 50ms for progress & to allow cancellation */
struct timespec ts = { .tv_sec = 0, .tv_nsec = 50 * 1000ull };
[...]
nanosleep(&ts, NULL);
The comment says 50ms (assuming m is for milli and not for micro.
because normally u is used for micro) but the actual nanosleep call is
done with 50 microseconds.
Is the comment right and the code wrong? I assume so, because 50
microseconds is pretty short and 50 milliseconds sounds more
reasonable.
Matthias
14 years, 8 months