[libvirt] [PATCH] docs: fix encryption format attribute in example
by Ján Tomko
The correct attribute name is 'format', not 'type'.
https://bugzilla.redhat.com/show_bug.cgi?id=1139910
---
Pushed as trivial.
docs/formatstorageencryption.html.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/docs/formatstorageencryption.html.in b/docs/formatstorageencryption.html.in
index 2b22237..04c3346 100644
--- a/docs/formatstorageencryption.html.in
+++ b/docs/formatstorageencryption.html.in
@@ -35,7 +35,7 @@
</p>
<h3><a name="StorageEncryptionDefault">"default" format</a></h3>
<p>
- <code><encryption type="default"/></code> can be specified only
+ <code><encryption format="default"/></code> can be specified only
when creating a volume. If the volume is successfully created, the
encryption formats, parameters and secrets will be auto-generated by
libvirt and the attached <code>encryption</code> tag will be updated.
--
1.8.5.5
10 years, 7 months
[libvirt] [PATCHv2 00/13] vbox: Rewrite vbox network driver
by Taowei
This series of patches rewrite the vbox network driver, which
is a continuance for my GSoC project "Rewriting the vbox driver".
The patches removed all version specified network drivers and
left a common driver which using vbox's uniformed network API.
Diff from v1:
*Remove macro VBOX_OBJECT_HOST_CHECK
*Code style improvements.
Taowei (13):
vbox: Rewrite vboxNetworkOpen
vbox: Rewrite vboxNetworkClose
vbox: Rewrite vboxConnectNumOfNetworks
vbox: Rewrite vboxConnectListNetworks
vbox: Rewrite vboxConnectNumOfDefinedNetworks
vbox: Rewrite vboxConnectListDefinedNetworks
vbox: Rewrite vboxNetworkLookupByUUID
vbox: Rewrite vboxNetworkLookupByName
vbox: Rewrite vboxNetworkDefineCreateXML
vbox: Rewrite vboxNetworkUndefineDestroy
vbox: Rewrite vboxNetworkCreate
vbox: Rewrite vboxNetworkGetXMLDesc
vbox: Introducing vboxCommonNetworkDriver
src/vbox/vbox_common.c | 942 ++++++++++++++++++++++++++++++
src/vbox/vbox_common.h | 16 +
src/vbox/vbox_driver.c | 23 +-
src/vbox/vbox_tmpl.c | 1261 +++++++++++------------------------------
src/vbox/vbox_uniformed_api.h | 52 ++
5 files changed, 1341 insertions(+), 953 deletions(-)
--
1.7.9.5
10 years, 7 months
[libvirt] [PATCH V1 0/4] xen-xl parser
by Kiarie Kahurani
Kiarie Kahurani (4):
src/xenconfig: Export helper functions
src/xenconfig: Xen-xl parser
src/xenconfig: Introduce xen-xl on virsh command line
tests: Tests for the xen-xl parser
configure.ac | 5 +-
src/Makefile.am | 21 +-
src/libvirt_xenconfig.syms | 4 +
src/libxl/libxl_driver.c | 46 ++-
src/xenconfig/libxlu_disk_i.h | 28 ++
src/xenconfig/libxlu_disk_l.l | 292 ++++++++++++++
src/xenconfig/xen_common.c | 147 +++----
src/xenconfig/xen_common.h | 24 +-
src/xenconfig/xen_xl.c | 476 +++++++++++++++++++++++
src/xenconfig/xen_xl.h | 29 ++
tests/Makefile.am | 9 +-
tests/testutilsxen.c | 50 +++
tests/testutilsxen.h | 9 +-
tests/xlconfigdata/test-disk-key-value.cfg | 27 ++
tests/xlconfigdata/test-disk-key-value.xml | 48 +++
tests/xlconfigdata/test-fullvirt-cdrom-empty.cfg | 23 ++
tests/xlconfigdata/test-fullvirt-cdrom-empty.xml | 0
tests/xlconfigdata/test-fullvirt-new-disk.cfg | 28 ++
tests/xlconfigdata/test-fullvirt-new-disk.xml | 46 +++
tests/xlconfigdata/test-fullvirt-spice.cfg | 32 ++
tests/xlconfigdata/test-fullvirt-spice.xml | 48 +++
tests/xlconfigdata/test.cfg | 48 +++
tests/xlconfigdata/test.xml | 48 +++
tests/xlconfigtest.c | 222 +++++++++++
24 files changed, 1613 insertions(+), 97 deletions(-)
create mode 100644 src/xenconfig/libxlu_disk_i.h
create mode 100644 src/xenconfig/libxlu_disk_l.l
create mode 100644 src/xenconfig/xen_xl.c
create mode 100644 src/xenconfig/xen_xl.h
create mode 100644 tests/xlconfigdata/test-disk-key-value.cfg
create mode 100644 tests/xlconfigdata/test-disk-key-value.xml
create mode 100644 tests/xlconfigdata/test-fullvirt-cdrom-empty.cfg
create mode 100644 tests/xlconfigdata/test-fullvirt-cdrom-empty.xml
create mode 100644 tests/xlconfigdata/test-fullvirt-new-disk.cfg
create mode 100644 tests/xlconfigdata/test-fullvirt-new-disk.xml
create mode 100644 tests/xlconfigdata/test-fullvirt-spice.cfg
create mode 100644 tests/xlconfigdata/test-fullvirt-spice.xml
create mode 100644 tests/xlconfigdata/test.cfg
create mode 100644 tests/xlconfigdata/test.xml
create mode 100644 tests/xlconfigtest.c
This may not be in a very good shape but a review would be good for me.
I will follow up with a finer series.
changes since prepost
-changed to use a flex based scanner(from xen libxl) instead of
parsing disk config by hand
-split the patches
--
1.8.4.5
10 years, 7 months
[libvirt] [PATCH 0/2] bugfix: support dhcp network interfaces
by Gene Czarcinski
Support for a network such as -N dhcp,source=default was not working
in that dhclient was not being started. Although I am not sure what
the real problem is, the solution is to use g_spawn_sync() instead of
g_spawn_async() to start /sbin/dhclient.
The second patch addes "-v" to the dhclient arguments to improve debugging
info. The dhclient into will be in /var/log/messages the Secure Contrainer
host system and not in the container itself.
Gene Czarcinski (2):
for dhclient use g_spawn_sync instead of g_spawn_async
add -v to dhclient parameter arguments
libvirt-sandbox/libvirt-sandbox-init-common.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
--
1.9.3
10 years, 7 months
[libvirt] DHCP and secure containers
by Gene Czarcinski
OK, hopefully this mailing list is more active and I can get some
response to my questions.
---------------------------------------------------------------------------------------------------------------------
I have been "playing with" Secure Containers running a lighttpd server
and have it up and running. I used Adam's process
(https://www.happyassassin.net/2014/07/23/bridged-networking-for-libvirt-w...)
for getting a bridge defined when also running NetworkManager. I then
created a virtual network definition:
> <network>
> <name>net18</name>
> <uuid>8d19a05b-ac85-4e2a-88bc-5ca4cbb29a33</uuid>
> <forward mode='bridge'/>
> <bridge name='br0'/>
> </network>
This works fine when I use static addresses such as:
> -N
> source=net18,address=192.168.18.94/24,route=192.168.18.255%192.168.18.1
but does not work when I specify using dhcp:
> -N source=net18,dhcp
I have reported this as a bug:
https://bugzilla.redhat.com/show_bug.cgi?id=1133686
Since there has not been much of a reaction to the BZ report, I decided
to take a look at the source code (it sure would have been nice if the
SRPMS were there in the F20 fedora-virt-preview but I get the package
from development/21).
I see that libvirt-sandbox-init-common.c has the code for starting dhcp
and also has main() along with some runtime options for -v verbose and
-d debug.
OK, how do I go about turning verbose and/or debug on?
Any suggestions on how to debug and get dhcp to work? I not only want
to find the problem but to fix the problem if needed.
Gene
10 years, 7 months
[libvirt] [PATCH v6 0/3] OVMF exposure
by Michal Privoznik
Diff to v5:
- changed readonly='on|off' to readonly='yes|no'
- rebased to current upstream
Michal Privoznik (3):
conf: Extend <loader/> and introduce <nvram/>
qemu: Implement extended loader and nvram
qemu: Automatically create NVRAM store
docs/formatdomain.html.in | 22 +++-
docs/schemas/domaincommon.rng | 28 +++++
libvirt.spec.in | 2 +
src/Makefile.am | 1 +
src/conf/domain_conf.c | 96 ++++++++++++++-
src/conf/domain_conf.h | 23 +++-
src/libvirt_private.syms | 3 +
src/qemu/libvirtd_qemu.aug | 3 +
src/qemu/qemu.conf | 14 +++
src/qemu/qemu_command.c | 97 ++++++++++++++-
src/qemu/qemu_conf.c | 94 ++++++++++++++
src/qemu/qemu_conf.h | 5 +
src/qemu/qemu_process.c | 137 +++++++++++++++++++++
src/qemu/test_libvirtd_qemu.aug.in | 3 +
src/security/security_dac.c | 8 ++
src/security/security_selinux.c | 8 ++
src/security/virt-aa-helper.c | 4 +-
src/vbox/vbox_common.c | 7 +-
src/xenapi/xenapi_driver.c | 3 +-
src/xenconfig/xen_common.c | 7 +-
src/xenconfig/xen_sxpr.c | 16 +--
tests/domainschemadata/domain-bios-nvram-empty.xml | 40 ++++++
.../qemuxml2argvdata/qemuxml2argv-bios-nvram.args | 10 ++
tests/qemuxml2argvdata/qemuxml2argv-bios-nvram.xml | 40 ++++++
tests/qemuxml2argvtest.c | 2 +
.../qemuxml2xmlout-pci-bridge-many-disks.xml | 2 +-
tests/qemuxml2xmltest.c | 2 +
tests/sexpr2xmldata/sexpr2xml-fv-autoport.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-fv-empty-kernel.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-fv-force-hpet.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-fv-force-nohpet.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-fv-kernel.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-fv-legacy-vfb.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-fv-localtime.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-fv-net-ioemu.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-fv-net-netfront.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-fv-parallel-tcp.xml | 2 +-
.../sexpr2xml-fv-serial-dev-2-ports.xml | 2 +-
.../sexpr2xml-fv-serial-dev-2nd-port.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-fv-serial-file.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-fv-serial-null.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-fv-serial-pipe.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-fv-serial-pty.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-fv-serial-stdio.xml | 2 +-
.../sexpr2xml-fv-serial-tcp-telnet.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-fv-serial-tcp.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-fv-serial-udp.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-fv-serial-unix.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-fv-sound-all.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-fv-sound.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-fv-usbmouse.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-fv-usbtablet.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-fv-utc.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-fv-v2.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-fv.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-no-source-cdrom.xml | 2 +-
tests/xmconfigdata/test-escape-paths.xml | 2 +-
tests/xmconfigdata/test-fullvirt-force-hpet.xml | 2 +-
tests/xmconfigdata/test-fullvirt-force-nohpet.xml | 2 +-
tests/xmconfigdata/test-fullvirt-localtime.xml | 2 +-
tests/xmconfigdata/test-fullvirt-net-ioemu.xml | 2 +-
tests/xmconfigdata/test-fullvirt-net-netfront.xml | 2 +-
tests/xmconfigdata/test-fullvirt-new-cdrom.xml | 2 +-
tests/xmconfigdata/test-fullvirt-old-cdrom.xml | 2 +-
tests/xmconfigdata/test-fullvirt-parallel-tcp.xml | 2 +-
.../test-fullvirt-serial-dev-2-ports.xml | 2 +-
.../test-fullvirt-serial-dev-2nd-port.xml | 2 +-
tests/xmconfigdata/test-fullvirt-serial-file.xml | 2 +-
tests/xmconfigdata/test-fullvirt-serial-null.xml | 2 +-
tests/xmconfigdata/test-fullvirt-serial-pipe.xml | 2 +-
tests/xmconfigdata/test-fullvirt-serial-pty.xml | 2 +-
tests/xmconfigdata/test-fullvirt-serial-stdio.xml | 2 +-
.../test-fullvirt-serial-tcp-telnet.xml | 2 +-
tests/xmconfigdata/test-fullvirt-serial-tcp.xml | 2 +-
tests/xmconfigdata/test-fullvirt-serial-udp.xml | 2 +-
tests/xmconfigdata/test-fullvirt-serial-unix.xml | 2 +-
tests/xmconfigdata/test-fullvirt-sound.xml | 2 +-
tests/xmconfigdata/test-fullvirt-usbmouse.xml | 2 +-
tests/xmconfigdata/test-fullvirt-usbtablet.xml | 2 +-
tests/xmconfigdata/test-fullvirt-utc.xml | 2 +-
tests/xmconfigdata/test-no-source-cdrom.xml | 2 +-
tests/xmconfigdata/test-pci-devs.xml | 2 +-
82 files changed, 705 insertions(+), 82 deletions(-)
create mode 100644 tests/domainschemadata/domain-bios-nvram-empty.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-bios-nvram.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-bios-nvram.xml
--
1.8.5.5
10 years, 7 months
[libvirt] [PATCH] virsh: additional scaled output units
by Eric Blake
The parser accepts P and E, so the formatter should too.
* tools/virsh.c (vshPrettyCapacity): Handle larger units.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
tools/virsh.c | 38 ++++++++++++++++++++++++++++----------
1 file changed, 28 insertions(+), 10 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 9706acc..64195a4 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -151,22 +151,40 @@ vshNameSorter(const void *a, const void *b)
double
vshPrettyCapacity(unsigned long long val, const char **unit)
{
- if (val < 1024) {
+ double limit = 1024;
+
+ if (val < limit) {
*unit = "B";
- return (double)val;
- } else if (val < (1024.0l * 1024.0l)) {
+ return val;
+ }
+ limit *= 1024;
+ if (val < limit) {
*unit = "KiB";
- return (((double)val / 1024.0l));
- } else if (val < (1024.0l * 1024.0l * 1024.0l)) {
+ return val / (limit / 1024);
+ }
+ limit *= 1024;
+ if (val < limit) {
*unit = "MiB";
- return (double)val / (1024.0l * 1024.0l);
- } else if (val < (1024.0l * 1024.0l * 1024.0l * 1024.0l)) {
+ return val / (limit / 1024);
+ }
+ limit *= 1024;
+ if (val < limit) {
*unit = "GiB";
- return (double)val / (1024.0l * 1024.0l * 1024.0l);
- } else {
+ return val / (limit / 1024);
+ }
+ limit *= 1024;
+ if (val < limit) {
*unit = "TiB";
- return (double)val / (1024.0l * 1024.0l * 1024.0l * 1024.0l);
+ return val / (limit / 1024);
}
+ limit *= 1024;
+ if (val < limit) {
+ *unit = "PiB";
+ return val / (limit / 1024);
+ }
+ limit *= 1024;
+ *unit = "EiB";
+ return val / (limit / 1024);
}
/*
--
1.9.3
10 years, 7 months
[libvirt] [PATCH] virNetSocketNewConnectUNIX: create socket dir if needed
by Serge Hallyn
Since 1b807f92dbb617db5b9d551777d3026d8ff0903f, if ~/.cache
does not exist, 'virsh -c qemu:///session' fails, because
it attempts to bind to ~/.cache/libvirt/libvirt-sock.
Create the socket's directory if needed.
Signed-off-by: Serge Hallyn <serge.hallyn(a)ubuntu.com>
---
src/rpc/virnetsocket.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c
index 586a0d7..14f8cca 100644
--- a/src/rpc/virnetsocket.c
+++ b/src/rpc/virnetsocket.c
@@ -598,6 +598,10 @@ int virNetSocketNewConnectUNIX(const char *path,
if (pid == 0) {
umask(0077);
+ if (path[0] != '@') {
+ if (virFileMakeParentPath(path) < 0)
+ virReportSystemError(errno, "%s", _("Failed to create directory"));
+ }
if (bind(passfd, &remoteAddr.data.sa, remoteAddr.len) < 0)
_exit(EXIT_FAILURE);
--
2.1.0
10 years, 7 months
[libvirt] [PATCH] qemu: Pass file descriptor when using TPM passthrough
by Stefan Berger
From: Stefan Berger <stefanb(a)linux.vnet.ibm.com>
Pass the TPM file descriptor to QEMU via command line.
Instead of passing /dev/tpm0 we now pass /dev/fdset/10 and the additional
parameters -add-fd set=10,fd=20.
This addresses the use case when QEMU is started with non-root privileges
and QEMU cannot open /dev/tpm0 for example.
One problem is that for the passing of the file descriptor set to work,
virCommandReorderFDs must not be called on the virCommand. This is prevented
by setting a flag in the virCommandPassFDGetFDIndex that is checked to be
clear when virCommandReorderFDs is run.
Signed-off-by: Stefan Berger <stefanb(a)linux.vnet.ibm.com>
---
src/libvirt_private.syms | 1 +
src/qemu/qemu_command.c | 132 ++++++++++++++++++++++++++++++++++++++++++++---
src/util/vircommand.c | 33 ++++++++++++
src/util/vircommand.h | 3 ++
4 files changed, 162 insertions(+), 7 deletions(-)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 10ebd12..b203398 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1149,6 +1149,7 @@ virCommandNewArgList;
virCommandNewArgs;
virCommandNonblockingFDs;
virCommandPassFD;
+virCommandPassFDGetFDIndex;
virCommandPassListenFDs;
virCommandRawStatus;
virCommandRequireHandshake;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 7b87a31..950d212 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -157,6 +157,58 @@ VIR_ENUM_IMPL(qemuNumaPolicy, VIR_DOMAIN_NUMATUNE_MEM_LAST,
"interleave");
/**
+ * qemuVirCommandGetFDSet:
+ * @cmd: the command to modify
+ * @fd: fd to reassign to the child
+ *
+ * Get the parameters for the QEMU -add-fd command line option
+ * for the given file descriptor. The file descriptor must previously
+ * have been 'transferred' in a virCommandPassFD() call.
+ * This function for example returns "set=10,fd=20".
+ */
+static char *
+qemuVirCommandGetFDSet(virCommandPtr cmd, int fd)
+{
+ char *result = NULL;
+ int idx = virCommandPassFDGetFDIndex(cmd, fd);
+
+ if (idx >= 0) {
+ ignore_value(virAsprintf(&result, "set=%d,fd=%d", idx, fd) < 0);
+ } else {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("file descriptor %d has not been transferred"), fd);
+ }
+
+ return result;
+}
+
+/**
+ * qemuVirCommandGetDevSet:
+ * @cmd: the command to modify
+ * @fd: fd to reassign to the child
+ *
+ * Get the parameters for the QEMU path= parameter where a file
+ * descriptor is accessed via a file descriptor set, for example
+ * /dev/fdset/10. The file descriptor must previously have been
+ * 'transferred' in a virCommandPassFD() call.
+ */
+static char *
+qemuVirCommandGetDevSet(virCommandPtr cmd, int fd)
+{
+ char *result = NULL;
+ int idx = virCommandPassFDGetFDIndex(cmd, fd);
+
+ if (idx >= 0) {
+ ignore_value(virAsprintf(&result, "/dev/fdset/%d", idx) < 0);
+ } else {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("file descriptor %d has not been transferred"), fd);
+ }
+ return result;
+}
+
+
+/**
* qemuPhysIfaceConnect:
* @def: the definition of the VM (needed by 802.1Qbh and audit)
* @driver: pointer to the driver instance
@@ -5779,14 +5831,20 @@ qemuBuildRNGDeviceArgs(virCommandPtr cmd,
static char *qemuBuildTPMBackendStr(const virDomainDef *def,
+ virCommandPtr cmd,
virQEMUCapsPtr qemuCaps,
- const char *emulator)
+ const char *emulator,
+ int *tpmfd, int *cancelfd)
{
const virDomainTPMDef *tpm = def->tpm;
virBuffer buf = VIR_BUFFER_INITIALIZER;
const char *type = virDomainTPMBackendTypeToString(tpm->type);
- char *cancel_path;
+ char *cancel_path = NULL;
const char *tpmdev;
+ char *devset = NULL, *cancel_devset = NULL;
+
+ *tpmfd = -1;
+ *cancelfd = -1;
virBufferAsprintf(&buf, "%s,id=tpm-%s", type, tpm->info.alias);
@@ -5799,11 +5857,47 @@ static char *qemuBuildTPMBackendStr(const virDomainDef *def,
if (!(cancel_path = virTPMCreateCancelPath(tpmdev)))
goto error;
- virBufferAddLit(&buf, ",path=");
- virBufferEscape(&buf, ',', ",", "%s", tpmdev);
+ if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_ADD_FD)) {
+ *tpmfd = open(tpmdev, O_RDWR);
+ if (*tpmfd < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Could not open TPM device %s"), tpmdev);
+ goto error;
+ }
+
+ virCommandPassFD(cmd, *tpmfd,
+ VIR_COMMAND_PASS_FD_CLOSE_PARENT);
+ devset = qemuVirCommandGetDevSet(cmd, *tpmfd);
+ if (devset == NULL)
+ goto error;
+
+ *cancelfd = open(cancel_path, O_WRONLY);
+ if (*cancelfd < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Could not open TPM device's cancel path "
+ "%s"), cancel_path);
+ goto error;
+ }
+
+ virCommandPassFD(cmd, *cancelfd,
+ VIR_COMMAND_PASS_FD_CLOSE_PARENT);
+ cancel_devset = qemuVirCommandGetDevSet(cmd, *cancelfd);
+ if (cancel_devset == NULL)
+ goto error;
+
+ virBufferAddLit(&buf, ",path=");
+ virBufferEscape(&buf, ',', ",", "%s", devset);
- virBufferAddLit(&buf, ",cancel-path=");
- virBufferEscape(&buf, ',', ",", "%s", cancel_path);
+ virBufferAddLit(&buf, ",cancel-path=");
+ virBufferEscape(&buf, ',', ",", "%s", cancel_devset);
+ } else {
+ /* all test cases will use this path */
+ virBufferAddLit(&buf, ",path=");
+ virBufferEscape(&buf, ',', ",", "%s", tpmdev);
+
+ virBufferAddLit(&buf, ",cancel-path=");
+ virBufferEscape(&buf, ',', ",", "%s", cancel_path);
+ }
VIR_FREE(cancel_path);
break;
@@ -5823,6 +5917,10 @@ static char *qemuBuildTPMBackendStr(const virDomainDef *def,
emulator, type);
error:
+ VIR_FREE(devset);
+ VIR_FREE(cancel_devset);
+ VIR_FREE(cancel_path);
+
virBufferFreeAndReset(&buf);
return NULL;
}
@@ -8770,13 +8868,33 @@ qemuBuildCommandLine(virConnectPtr conn,
if (def->tpm) {
char *optstr;
+ int tpmfd = -1;
+ int cancelfd = -1;
+ char *fdset;
- if (!(optstr = qemuBuildTPMBackendStr(def, qemuCaps, emulator)))
+ if (!(optstr = qemuBuildTPMBackendStr(def, cmd, qemuCaps, emulator,
+ &tpmfd, &cancelfd)))
goto error;
virCommandAddArgList(cmd, "-tpmdev", optstr, NULL);
VIR_FREE(optstr);
+ if (tpmfd >= 0) {
+ fdset = qemuVirCommandGetFDSet(cmd, tpmfd);
+ if (!fdset)
+ goto error;
+
+ virCommandAddArgList(cmd, "-add-fd", fdset, NULL);
+ }
+
+ if (cancelfd >= 0) {
+ fdset = qemuVirCommandGetFDSet(cmd, cancelfd);
+ if (!fdset)
+ goto error;
+
+ virCommandAddArgList(cmd, "-add-fd", fdset, NULL);
+ }
+
if (!(optstr = qemuBuildTPMDevStr(def, qemuCaps, emulator)))
goto error;
diff --git a/src/util/vircommand.c b/src/util/vircommand.c
index cbe94f8..fd70e78 100644
--- a/src/util/vircommand.c
+++ b/src/util/vircommand.c
@@ -67,6 +67,7 @@ enum {
VIR_EXEC_RUN_SYNC = (1 << 3),
VIR_EXEC_ASYNC_IO = (1 << 4),
VIR_EXEC_LISTEN_FDS = (1 << 5),
+ VIR_EXEC_FIXED_FDS = (1 << 6),
};
typedef struct _virCommandFD virCommandFD;
@@ -214,6 +215,12 @@ virCommandReorderFDs(virCommandPtr cmd)
if (!cmd || cmd->has_error || !cmd->npassfd)
return;
+ if ((cmd->flags & VIR_EXEC_FIXED_FDS)) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("The fds are fixed and cannot be reordered"));
+ goto error;
+ }
+
for (i = 0; i < cmd->npassfd; i++)
maxfd = MAX(cmd->passfd[i].fd, maxfd);
@@ -1020,6 +1027,32 @@ virCommandPassListenFDs(virCommandPtr cmd)
cmd->flags |= VIR_EXEC_LISTEN_FDS;
}
+/*
+ * virCommandPassFDGetFDIndex:
+ * @cmd: pointer to virCommand
+ * @fd: FD to get index of
+ *
+ * Determine the index of the FD in the transfer set.
+ *
+ * Returns index >= 0 if @set contains @fd,
+ * -1 otherwise.
+ */
+int
+virCommandPassFDGetFDIndex(virCommandPtr cmd, int fd)
+{
+ size_t i = 0;
+
+ while (i < cmd->npassfd) {
+ if (cmd->passfd[i].fd == fd) {
+ cmd->flags |= VIR_EXEC_FIXED_FDS;
+ return i;
+ }
+ i++;
+ }
+
+ return -1;
+}
+
/**
* virCommandSetPidFile:
* @cmd: the command to modify
diff --git a/src/util/vircommand.h b/src/util/vircommand.h
index bf65de4..198da2f 100644
--- a/src/util/vircommand.h
+++ b/src/util/vircommand.h
@@ -62,6 +62,9 @@ void virCommandPassFD(virCommandPtr cmd,
void virCommandPassListenFDs(virCommandPtr cmd);
+int virCommandPassFDGetFDIndex(virCommandPtr cmd,
+ int fd);
+
void virCommandSetPidFile(virCommandPtr cmd,
const char *pidfile) ATTRIBUTE_NONNULL(2);
--
1.9.3
10 years, 7 months
[libvirt] [PATCH] network: check for invalid forward delay time
by Erik Skultety
When spanning tree protocol is allowed in bridge settings, forward delay
value is set as well (default is 0 if omitted). Until now, there was no
check for delay value validity. Delay makes sense only as a positive
numerical value.
Note: However, even if you provide positive numerical value, brctl
utility only uses values from range <2,30>, so the number provided can
be modified (kernel most likely) to fall within this range.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1125764
---
docs/schemas/network.rng | 2 +-
src/conf/network_conf.c | 18 +++++++++++++-----
src/util/virxml.c | 2 +-
3 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/docs/schemas/network.rng b/docs/schemas/network.rng
index 0e7da89..ab41814 100644
--- a/docs/schemas/network.rng
+++ b/docs/schemas/network.rng
@@ -62,7 +62,7 @@
<optional>
<attribute name="delay">
- <data type="integer"/>
+ <data type="unsignedLong"/>
</attribute>
</optional>
diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index 9571ee1..4d6db8c 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -2016,6 +2016,7 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt)
xmlNodePtr save = ctxt->node;
xmlNodePtr bandwidthNode = NULL;
xmlNodePtr vlanNode;
+ int ret = 0;
if (VIR_ALLOC(def) < 0)
return NULL;
@@ -2078,8 +2079,15 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt)
stp = virXPathString("string(./bridge[1]/@stp)", ctxt);
def->stp = (stp && STREQ(stp, "off")) ? false : true;
- if (virXPathULong("string(./bridge[1]/@delay)", ctxt, &def->delay) < 0)
- def->delay = 0;
+ ret = virXPathULong("string(./bridge[1]/@delay)", ctxt, &def->delay);
+ if (ret == -2) {
+ virReportError(VIR_ERR_XML_ERROR,
+ _("Invalid delay value in network '%s'"),
+ def->name);
+ goto error;
+ } else if (ret < 0) {
+ def->delay = 0;
+ }
tmp = virXPathString("string(./mac[1]/@address)", ctxt);
if (tmp) {
@@ -2126,7 +2134,7 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt)
goto error;
/* parse each portgroup */
for (i = 0; i < nPortGroups; i++) {
- int ret = virNetworkPortGroupParseXML(&def->portGroups[i],
+ ret = virNetworkPortGroupParseXML(&def->portGroups[i],
portGroupNodes[i], ctxt);
if (ret < 0)
goto error;
@@ -2147,7 +2155,7 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt)
goto error;
/* parse each addr */
for (i = 0; i < nIps; i++) {
- int ret = virNetworkIPDefParseXML(def->name, ipNodes[i],
+ ret = virNetworkIPDefParseXML(def->name, ipNodes[i],
ctxt, &def->ips[i]);
if (ret < 0)
goto error;
@@ -2168,7 +2176,7 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt)
goto error;
/* parse each definition */
for (i = 0; i < nRoutes; i++) {
- int ret = virNetworkRouteDefParseXML(def->name, routeNodes[i],
+ ret = virNetworkRouteDefParseXML(def->name, routeNodes[i],
ctxt, &def->routes[i]);
if (ret < 0)
goto error;
diff --git a/src/util/virxml.c b/src/util/virxml.c
index cc4a85c..f730f5e 100644
--- a/src/util/virxml.c
+++ b/src/util/virxml.c
@@ -286,7 +286,7 @@ virXPathULongBase(const char *xpath,
ctxt->node = relnode;
if ((obj != NULL) && (obj->type == XPATH_STRING) &&
(obj->stringval != NULL) && (obj->stringval[0] != 0)) {
- if (virStrToLong_ul((char *) obj->stringval, NULL, base, value) < 0)
+ if (virStrToLong_ulp((char *) obj->stringval, NULL, base, value) < 0)
ret = -2;
} else if ((obj != NULL) && (obj->type == XPATH_NUMBER) &&
(!(isnan(obj->floatval)))) {
--
1.9.3
10 years, 7 months