[libvirt] [PATCH 0/8] virsh: kill blockJobImpl
by Peter Krempa
Move the code to appropriate parts to sanitize control flow.
Peter Krempa (8):
virsh: blockjob: Extract block job info code into a separate function
virsh: cmdBlockJob: Switch to declarative flag interlocking
virsh: blockjob: Split out vshBlockJobSetSpeed from blockJobImpl
virsh: man: Add missing dashes for blockjob --bandwidth
virsh: block job: Support --bytes and scaled integers when setting
speed
virsh: block job: separate abort from blockJobImpl
virsh: Split out block pull implementation from blockJobImpl
virsh: Kill blockJobImpl by moving the final impl into cmdBlockCommit
tools/virsh-domain.c | 314 +++++++++++++++++++++++++++++----------------------
tools/virsh.pod | 14 ++-
2 files changed, 189 insertions(+), 139 deletions(-)
--
2.3.5
9 years, 6 months
[libvirt] [PATCH] libxl: include a XLU_Config in _libxlDriverConfig
by Olaf Hering
Upcoming changes for vscsi will use libxlutil.so to prepare the
configuration for libxl. The helpers needs a xlu struct for logging.
Provide one and reuse the existing output as log target.
Signed-off-by: Olaf Hering <olaf(a)aepfle.de>
Cc: Jim Fehlig <jfehlig(a)suse.com>
---
src/libxl/libxl_conf.c | 6 ++++++
src/libxl/libxl_conf.h | 7 +++++++
2 files changed, 13 insertions(+)
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index 53f327b..f9bb5ed 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -1454,6 +1454,12 @@ libxlDriverConfigNew(void)
goto error;
}
+ cfg->xlu = xlu_cfg_init(cfg->logger_file, "libvirt");
+ if (!cfg->xlu) {
+ VIR_ERROR(_("cannot create xlu for libxenlight, disabling driver"));
+ goto error;
+ }
+
if (libxl_ctx_alloc(&cfg->ctx, LIBXL_VERSION, 0, cfg->logger)) {
VIR_ERROR(_("cannot initialize libxenlight context, probably not "
"running in a Xen Dom0, disabling driver"));
diff --git a/src/libxl/libxl_conf.h b/src/libxl/libxl_conf.h
index 5ba1a71..bdc68d4 100644
--- a/src/libxl/libxl_conf.h
+++ b/src/libxl/libxl_conf.h
@@ -27,6 +27,12 @@
# define LIBXL_CONF_H
# include <libxl.h>
+#ifdef HAVE_LIBXLUTIL_H
+# include <libxlutil.h>
+#else
+typedef struct XLU_Config XLU_Config;
+XLU_Config *xlu_cfg_init(FILE *report, const char *report_filename);
+#endif
# include "internal.h"
# include "libvirt_internal.h"
@@ -91,6 +97,7 @@ struct _libxlDriverConfig {
/* log stream for driver-wide libxl ctx */
FILE *logger_file;
xentoollog_logger *logger;
+ XLU_Config *xlu;
/* libxl ctx for driver wide ops; getVersion, getNodeInfo, ... */
libxl_ctx *ctx;
9 years, 6 months
[libvirt] [PATCH] lxc: don't up the veth interfaces unless explicitly asked to
by Lubomir Rintel
Upping an interface for no reason and not configuring it is a cardinal sin.
With the default addrgenmode if eui64 it sticks a link-local address to the
interface. That is not good, as NetworkManager would see an address configured,
assume the interface is already configured and won't touch it iself and the
interface might stay unconfigured until the end of the days.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1124721
---
src/lxc/lxc_container.c | 2 +-
src/lxc/lxc_native.c | 10 ++++------
2 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index cc20b6d..50e38e9 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -541,7 +541,7 @@ static int lxcContainerRenameAndEnableInterfaces(virDomainDefPtr vmDef,
VIR_FREE(ipStr);
}
- if (netDef->linkstate != VIR_DOMAIN_NET_INTERFACE_LINK_STATE_DOWN) {
+ if (netDef->linkstate == VIR_DOMAIN_NET_INTERFACE_LINK_STATE_UP) {
VIR_DEBUG("Enabling %s", newname);
rc = virNetDevSetOnline(newname, true);
if (rc < 0)
diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c
index c15eb19..2297dbe 100644
--- a/src/lxc/lxc_native.c
+++ b/src/lxc/lxc_native.c
@@ -348,12 +348,10 @@ lxcCreateNetDef(const char *type,
if (VIR_ALLOC(net) < 0)
goto error;
- if (flag) {
- if (STREQ(flag, "up"))
- net->linkstate = VIR_DOMAIN_NET_INTERFACE_LINK_STATE_UP;
- else
- net->linkstate = VIR_DOMAIN_NET_INTERFACE_LINK_STATE_DOWN;
- }
+ if (flag && STREQ(flag, "up"))
+ net->linkstate = VIR_DOMAIN_NET_INTERFACE_LINK_STATE_UP;
+ else
+ net->linkstate = VIR_DOMAIN_NET_INTERFACE_LINK_STATE_DOWN;
if (VIR_STRDUP(net->ifname_guest, name) < 0)
goto error;
--
2.1.0
9 years, 6 months
[libvirt] [PATCH] libxl: initialize vfb defbools in libxlMakeVfb
by Olaf Hering
If the domU configu has sdl enabled libvirtd crashes:
libvirtd[5158]: libvirtd: libxl.c:343: libxl_defbool_val: Assertion `!libxl_defbool_is_default(db)' failed.
Initialize the relevant defbool variables in libxl_device_vfb.
Signed-off-by: Olaf Hering <olaf(a)aepfle.de>
Cc: Jim Fehlig <jfehlig(a)suse.com>
---
Seen in 1.2.14.
src/libxl/libxl_conf.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index 9b3c949..6feb7d9 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -1232,6 +1232,7 @@ libxlMakeVfb(virPortAllocatorPtr graphicsports,
switch (l_vfb->type) {
case VIR_DOMAIN_GRAPHICS_TYPE_SDL:
libxl_defbool_set(&x_vfb->sdl.enable, 1);
+ libxl_defbool_set(&x_vfb->vnc.enable, 0);
if (VIR_STRDUP(x_vfb->sdl.display, l_vfb->data.sdl.display) < 0)
return -1;
if (VIR_STRDUP(x_vfb->sdl.xauthority, l_vfb->data.sdl.xauth) < 0)
@@ -1239,6 +1240,7 @@ libxlMakeVfb(virPortAllocatorPtr graphicsports,
break;
case VIR_DOMAIN_GRAPHICS_TYPE_VNC:
libxl_defbool_set(&x_vfb->vnc.enable, 1);
+ libxl_defbool_set(&x_vfb->sdl.enable, 0);
/* driver handles selection of free port */
libxl_defbool_set(&x_vfb->vnc.findunused, 0);
if (l_vfb->data.vnc.autoport) {
9 years, 6 months
[libvirt] [PATCH] test: remove s390 tests used only for testing usb and ide controllers
by Laine Stump
Back in 2013, commit 877bc089 added in some tests that made sure no
error was generated on a domain definition that had an automatically
added usb controller if that domain didn't have a PCI bus to attach
the usb controller to. In particular, two s390-specific tests were
added, one with <controller type='usb' model='none'/> and another
(called "s390-piix-controllers") that had both usb and ide
controllers, but nothing attached to them.
Then in February of this year, commit 09ab9dcc eliminated the annoying
auto-adding of a usb device for s390 and s390x machines, stating:
"Since s390 does not support usb the default creation of a usb
controller for a domain should not occur."
Since s390 doesn't support usb and usb controllers aren't added to
s390 domain definitions automatically, there is no reason to have the
tests with a usb controller and expect them to succeed. And since the
only reference of an IDE controller wrt s390 that I've found is in the
one test case mentioned above, and the commit log that added it
specifically mentions the purpose to be quieting error messages on
machines with no PCI bus, I'm assuming that the s390 also doesn't
support IDE controllers. Based on that reasoning (and the fact that
s390-piix-controllers causes a test error for an upcoming patch), this
patch removes those two tests.
---
.../qemuxml2argv-s390-piix-controllers.args | 12 --------
.../qemuxml2argv-s390-piix-controllers.xml | 34 ----------------------
.../qemuxml2argv-s390-usb-none.args | 12 --------
.../qemuxml2argv-s390-usb-none.xml | 29 ------------------
tests/qemuxml2argvtest.c | 10 -------
5 files changed, 97 deletions(-)
delete mode 100644 tests/qemuxml2argvdata/qemuxml2argv-s390-piix-controllers.args
delete mode 100644 tests/qemuxml2argvdata/qemuxml2argv-s390-piix-controllers.xml
delete mode 100644 tests/qemuxml2argvdata/qemuxml2argv-s390-usb-none.args
delete mode 100644 tests/qemuxml2argvdata/qemuxml2argv-s390-usb-none.xml
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-s390-piix-controllers.args b/tests/qemuxml2argvdata/qemuxml2argv-s390-piix-controllers.args
deleted file mode 100644
index e939be4..0000000
--- a/tests/qemuxml2argvdata/qemuxml2argv-s390-piix-controllers.args
+++ /dev/null
@@ -1,12 +0,0 @@
-LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
-/usr/bin/qemu-system-s390x -S -M s390-virtio -m 214 -smp 1 -nographic \
--nodefconfig -nodefaults \
--chardev socket,id=charmonitor,path=/tmp/test-monitor,server,nowait \
--mon chardev=charmonitor,id=monitor,mode=readline -no-acpi \
--device virtio-serial-s390,id=virtio-serial0 -drive \
-file=/dev/HostVG/QEMUGuest1,if=none,id=drive-virtio-disk0 \
--device virtio-blk-s390,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \
--chardev pty,id=charconsole0 \
--device virtconsole,chardev=charconsole0,id=console0 \
--object rng-random,id=objrng0,filename=/dev/hwrng \
--device virtio-rng-s390,rng=objrng0,id=rng0
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-s390-piix-controllers.xml b/tests/qemuxml2argvdata/qemuxml2argv-s390-piix-controllers.xml
deleted file mode 100644
index a8b72d7..0000000
--- a/tests/qemuxml2argvdata/qemuxml2argv-s390-piix-controllers.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<domain type='qemu'>
- <name>test</name>
- <memory>219100</memory>
- <currentMemory>219100</currentMemory>
- <os>
- <type arch='s390x' machine='s390-virtio'>hvm</type>
- </os>
- <clock offset='utc'/>
- <on_poweroff>destroy</on_poweroff>
- <on_reboot>restart</on_reboot>
- <on_crash>destroy</on_crash>
- <devices>
- <emulator>/usr/bin/qemu-system-s390x</emulator>
- <disk type='block' device='disk'>
- <source dev='/dev/HostVG/QEMUGuest1'/>
- <target dev='hda' bus='virtio'/>
- <boot order='1'/>
- </disk>
- <console type='pty'>
- <target type='virtio'/>
- </console>
- <controller type='usb' index='0'>
- <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
- </controller>
- <controller type='ide' index='0'>
- <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
- </controller>
- <memballoon model='virtio'>
- </memballoon>
- <rng model='virtio'>
- <backend model='random'>/dev/hwrng</backend>
- </rng>
- </devices>
-</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-s390-usb-none.args b/tests/qemuxml2argvdata/qemuxml2argv-s390-usb-none.args
deleted file mode 100644
index 51fcfa6..0000000
--- a/tests/qemuxml2argvdata/qemuxml2argv-s390-usb-none.args
+++ /dev/null
@@ -1,12 +0,0 @@
-LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
-/usr/bin/qemu-system-s390x -S -M s390-virtio -m 214 -smp 1 \
--nographic -nodefconfig -nodefaults \
--chardev socket,id=charmonitor,path=/tmp/test-monitor,server,nowait \
--mon chardev=charmonitor,id=monitor,mode=readline -no-acpi \
--device virtio-serial-s390,id=virtio-serial0 \
--drive file=/dev/HostVG/QEMUGuest1,if=none,id=drive-virtio-disk0 \
--device virtio-blk-s390,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \
--chardev pty,id=charconsole0 \
--device virtconsole,chardev=charconsole0,id=console0 \
--object rng-random,id=objrng0,filename=/dev/hwrng \
--device virtio-rng-s390,rng=objrng0,id=rng0
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-s390-usb-none.xml b/tests/qemuxml2argvdata/qemuxml2argv-s390-usb-none.xml
deleted file mode 100644
index f2977b5..0000000
--- a/tests/qemuxml2argvdata/qemuxml2argv-s390-usb-none.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<domain type='qemu'>
- <name>test</name>
- <memory>219100</memory>
- <currentMemory>219100</currentMemory>
- <os>
- <type arch='s390x' machine='s390-virtio'>hvm</type>
- </os>
- <clock offset='utc'/>
- <on_poweroff>destroy</on_poweroff>
- <on_reboot>restart</on_reboot>
- <on_crash>destroy</on_crash>
- <devices>
- <emulator>/usr/bin/qemu-system-s390x</emulator>
- <disk type='block' device='disk'>
- <source dev='/dev/HostVG/QEMUGuest1'/>
- <target dev='hda' bus='virtio'/>
- <boot order='1'/>
- </disk>
- <console type='pty'>
- <target type='virtio'/>
- </console>
- <controller type='usb' index='0' model='none'/>
- <memballoon model='virtio'>
- </memballoon>
- <rng model='virtio'>
- <backend model='random'>/dev/hwrng</backend>
- </rng>
- </devices>
-</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 0763068..da5afd4 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1405,16 +1405,6 @@ mymain(void)
QEMU_CAPS_VIRTIO_S390, QEMU_CAPS_DEVICE_VIRTIO_RNG,
QEMU_CAPS_OBJECT_RNG_RANDOM);
- DO_TEST("s390-usb-none",
- QEMU_CAPS_DEVICE, QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG,
- QEMU_CAPS_DRIVE, QEMU_CAPS_BOOTINDEX, QEMU_CAPS_VIRTIO_S390,
- QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM);
-
- DO_TEST("s390-piix-controllers",
- QEMU_CAPS_DEVICE, QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG,
- QEMU_CAPS_DRIVE, QEMU_CAPS_BOOTINDEX, QEMU_CAPS_VIRTIO_S390,
- QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM);
-
DO_TEST("ppc-dtb", QEMU_CAPS_KVM, QEMU_CAPS_DTB);
DO_TEST("ppce500-serial", QEMU_CAPS_KVM, QEMU_CAPS_DEVICE, QEMU_CAPS_CHARDEV);
--
2.1.0
9 years, 6 months
[libvirt] [PATCH] libxl: add logrotate config file
by Jim Fehlig
Add logrotate config for log files in /var/log/libvirt/libxl.
Signed-off-by: Jim Fehlig <jfehlig(a)suse.com>
---
daemon/Makefile.am | 13 ++++++++++++-
daemon/libvirtd.libxl.logrotate.in | 9 +++++++++
libvirt.spec.in | 3 +++
3 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/daemon/Makefile.am b/daemon/Makefile.am
index 300b9a5..b19a126 100644
--- a/daemon/Makefile.am
+++ b/daemon/Makefile.am
@@ -62,6 +62,7 @@ EXTRA_DIST = \
libvirtd.logrotate.in \
libvirtd.qemu.logrotate.in \
libvirtd.lxc.logrotate.in \
+ libvirtd.libxl.logrotate.in \
libvirtd.uml.logrotate.in \
test_libvirtd.aug.in \
THREADS.txt \
@@ -275,7 +276,8 @@ remote.c: $(DAEMON_GENERATED)
remote.h: $(DAEMON_GENERATED)
LOGROTATE_CONFS = libvirtd.qemu.logrotate libvirtd.lxc.logrotate \
- libvirtd.uml.logrotate libvirtd.logrotate
+ libvirtd.libxl.logrotate libvirtd.uml.logrotate \
+ libvirtd.logrotate
BUILT_SOURCES += $(LOGROTATE_CONFS)
@@ -297,6 +299,12 @@ libvirtd.lxc.logrotate: libvirtd.lxc.logrotate.in
< $< > $@-t && \
mv $@-t $@
+libvirtd.libxl.logrotate: libvirtd.libxl.logrotate.in
+ $(AM_V_GEN)sed \
+ -e 's|[@]localstatedir[@]|$(localstatedir)|g' \
+ < $< > $@-t && \
+ mv $@-t $@
+
libvirtd.uml.logrotate: libvirtd.uml.logrotate.in
$(AM_V_GEN)sed \
-e 's|[@]localstatedir[@]|$(localstatedir)|g' \
@@ -314,6 +322,8 @@ install-logrotate: $(LOGROTATE_CONFS)
$(DESTDIR)$(sysconfdir)/logrotate.d/libvirtd.qemu
$(INSTALL_DATA) libvirtd.lxc.logrotate \
$(DESTDIR)$(sysconfdir)/logrotate.d/libvirtd.lxc
+ $(INSTALL_DATA) libvirtd.libxl.logrotate \
+ $(DESTDIR)$(sysconfdir)/logrotate.d/libvirtd.libxl
$(INSTALL_DATA) libvirtd.uml.logrotate \
$(DESTDIR)$(sysconfdir)/logrotate.d/libvirtd.uml
@@ -321,6 +331,7 @@ uninstall-logrotate:
rm -f $(DESTDIR)$(sysconfdir)/logrotate.d/libvirtd \
$(DESTDIR)$(sysconfdir)/logrotate.d/libvirtd.qemu \
$(DESTDIR)$(sysconfdir)/logrotate.d/libvirtd.lxc \
+ $(DESTDIR)$(sysconfdir)/logrotate.d/libvirtd.libxl \
$(DESTDIR)$(sysconfdir)/logrotate.d/libvirtd.uml
rmdir $(DESTDIR)$(localstatedir)/log/libvirt/qemu || :
rmdir $(DESTDIR)$(localstatedir)/log/libvirt/lxc || :
diff --git a/daemon/libvirtd.libxl.logrotate.in b/daemon/libvirtd.libxl.logrotate.in
new file mode 100644
index 0000000..523b2f8
--- /dev/null
+++ b/daemon/libvirtd.libxl.logrotate.in
@@ -0,0 +1,9 @@
+@localstatedir(a)/log/libvirt/libxl/*.log {
+ weekly
+ missingok
+ rotate 4
+ compress
+ delaycompress
+ copytruncate
+ minsize 100k
+}
diff --git a/libvirt.spec.in b/libvirt.spec.in
index f95e31f..3feda9d 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -1601,6 +1601,7 @@ rm -rf $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/libvirtd.lxc
%endif
%if ! %{with_libxl}
rm -rf $RPM_BUILD_ROOT%{_sysconfdir}/libvirt/libxl.conf
+rm -rf $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/libvirtd.libxl
rm -f $RPM_BUILD_ROOT%{_datadir}/augeas/lenses/libvirtd_libxl.aug
rm -f $RPM_BUILD_ROOT%{_datadir}/augeas/lenses/tests/test_libvirtd_libxl.aug
%endif
@@ -2007,6 +2008,7 @@ exit 0
%endif
%if %{with_libxl}
%config(noreplace) %{_sysconfdir}/libvirt/libxl.conf
+%config(noreplace) %{_sysconfdir}/logrotate.d/libvirtd.libxl
%dir %attr(0700, root, root) %{_localstatedir}/log/libvirt/libxl/
%ghost %dir %{_localstatedir}/run/libvirt/libxl/
%dir %attr(0700, root, root) %{_localstatedir}/lib/libvirt/libxl/
@@ -2129,6 +2131,7 @@ exit 0
%files daemon-driver-libxl
%defattr(-, root, root)
%config(noreplace) %{_sysconfdir}/libvirt/libxl.conf
+%config(noreplace) %{_sysconfdir}/logrotate.d/libvirtd.libxl
%config(noreplace) %{_sysconfdir}/libvirt/libxl-lockd.conf
%config(noreplace) %{_sysconfdir}/libvirt/libxl-sanlock.conf
%{_datadir}/augeas/lenses/libvirtd_libxl.aug
--
1.8.4.5
9 years, 6 months
[libvirt] [PATCH4/3] qemu: add cpu feature check for host-passthrough
by Luyao Huang
Signed-off-by: Luyao Huang <lhuang(a)redhat.com>
---
I forgot this place.
src/qemu/qemu_process.c | 5 -----
1 file changed, 5 deletions(-)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 79f763e..5f418a9 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -4070,11 +4070,6 @@ qemuProcessVerifyGuestCPU(virQEMUDriverPtr driver,
bool ret = false;
size_t i;
- /* no features are passed to QEMU with -cpu host
- * so it makes no sense to verify them */
- if (def->cpu && def->cpu->mode == VIR_CPU_MODE_HOST_PASSTHROUGH)
- return true;
-
switch (arch) {
case VIR_ARCH_I686:
case VIR_ARCH_X86_64:
--
1.8.3.1
9 years, 6 months
[libvirt] [PATCH 0/3] fix some issue around host-passthough cpu model
by Luyao Huang
We support add feature in host-passthough cpu model, but there are
some place need fix.
Luyao Huang (3):
cpu:x86: fix cannot keep cpu feature after migrate/restore
qemu: add a check for non-migratable cpu flags
docs: fix a small xml error in docs
docs/formatdomain.html.in | 2 +-
src/cpu/cpu_x86.c | 9 ++++-----
src/qemu/qemu_migration.c | 2 +-
3 files changed, 6 insertions(+), 7 deletions(-)
--
1.8.3.1
9 years, 6 months
[libvirt] [PATCH v1] [libvirt-php] add stream support and upload/resize/download for volume
by Vasiliy Tolstov
This patch add to libvirt php binding libvirt stream support
Also provide resize/upload/download for libvirt volume
Signed-off-by: Vasiliy Tolstov <v.tolstov(a)selfip.ru>
---
configure.ac | 3 +-
src/libvirt-php.c | 382 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
src/libvirt-php.h | 17 +++
3 files changed, 395 insertions(+), 7 deletions(-)
diff --git a/configure.ac b/configure.ac
index b854153..7099f9d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,7 +1,6 @@
AC_INIT([libvirt-php], [0.5.0], [http://libvirt.org])
-AM_INIT_AUTOMAKE([-Wall -Werror])
+AM_INIT_AUTOMAKE([-Wall -Werror -Wno-portability])
AC_CONFIG_FILES([Makefile tools/Makefile src/Makefile tests/Makefile docs/Makefile])
-AM_INIT_AUTOMAKE([-Wno-portability])
AM_MAINTAINER_MODE([enable])
dnl Checks for programs.
diff --git a/src/libvirt-php.c b/src/libvirt-php.c
index 6d6fa81..0adc4be 100644
--- a/src/libvirt-php.c
+++ b/src/libvirt-php.c
@@ -61,6 +61,7 @@ int le_libvirt_storagepool;
int le_libvirt_volume;
int le_libvirt_network;
int le_libvirt_nodedev;
+int le_libvirt_stream;
#if LIBVIR_VERSION_NUMBER>=8000
int le_libvirt_snapshot;
#endif
@@ -90,6 +91,13 @@ static zend_function_entry libvirt_functions[] = {
PHP_FE(libvirt_connect_get_maxvcpus, NULL)
PHP_FE(libvirt_connect_get_encrypted, NULL)
PHP_FE(libvirt_connect_get_secure, NULL)
+ /* Stream functions */
+ PHP_FE(libvirt_stream_create, NULL)
+ PHP_FE(libvirt_stream_close, NULL)
+ PHP_FE(libvirt_stream_abort, NULL)
+ PHP_FE(libvirt_stream_finish, NULL)
+ PHP_FE(libvirt_stream_send, NULL)
+ PHP_FE(libvirt_stream_recv, NULL)
/* Domain functions */
PHP_FE(libvirt_domain_new, NULL)
PHP_FE(libvirt_domain_new_get_vnc, NULL)
@@ -148,7 +156,7 @@ static zend_function_entry libvirt_functions[] = {
PHP_FE(libvirt_domain_get_screen_dimensions, NULL)
PHP_FE(libvirt_domain_send_keys, NULL)
PHP_FE(libvirt_domain_send_pointer_event, NULL)
- PHP_FE(libvirt_domain_update_device, NULL)
+ PHP_FE(libvirt_domain_update_device, NULL)
/* Domain snapshot functions */
PHP_FE(libvirt_domain_has_current_snapshot, NULL)
PHP_FE(libvirt_domain_snapshot_create, NULL)
@@ -169,6 +177,9 @@ static zend_function_entry libvirt_functions[] = {
PHP_FE(libvirt_storagevolume_create_xml,NULL)
PHP_FE(libvirt_storagevolume_create_xml_from,NULL)
PHP_FE(libvirt_storagevolume_delete,NULL)
+ PHP_FE(libvirt_storagevolume_download,NULL)
+ PHP_FE(libvirt_storagevolume_upload,NULL)
+ PHP_FE(libvirt_storagevolume_resize,NULL)
PHP_FE(libvirt_storagepool_get_uuid_string, NULL)
PHP_FE(libvirt_storagepool_get_name, NULL)
PHP_FE(libvirt_storagepool_lookup_by_uuid_string, NULL)
@@ -370,6 +381,8 @@ char *translate_counter_type(int type)
break;
case INT_RESOURCE_DOMAIN: return "domain";
break;
+ case INT_RESOURCE_STREAM: return "stream";
+ break;
case INT_RESOURCE_NETWORK: return "network";
break;
case INT_RESOURCE_NODEDEV: return "node device";
@@ -444,7 +457,7 @@ void free_tokens(tTokenizer t)
Private function name: resource_change_counter
Since version: 0.4.2
Description: Function to increment (inc = 1) / decrement (inc = 0) the resource pointers count including the memory location
- Arguments: @type [int]: type of resource (INT_RESOURCE_x defines where x can be { CONNECTION | DOMAIN | NETWORK | NODEDEV | STORAGEPOOL | VOLUME | SNAPSHOT })
+ Arguments: @type [int]: type of resource (INT_RESOURCE_x defines where x can be { CONNECTION | DOMAIN | NETWORK | NODEDEV | STORAGEPOOL | VOLUME | SNAPSHOT | STREAM })
@conn [virConnectPtr]: libvirt connection pointer associated with the resource, NULL for libvirt connection objects
@mem [pointer]: Pointer to memory location for the resource. Will be converted to appropriate uint for the arch.
@inc [int/bool]: Increment the counter (1 = add memory location) or decrement the counter (0 = remove memory location) from entries.
@@ -724,6 +737,18 @@ void free_resource(int type, arch_uint mem TSRMLS_DC)
}
}
+ if (type == INT_RESOURCE_STREAM) {
+ rv = virStreamFree( (virStreamPtr)mem );
+ if (rv != 0) {
+ DPRINTF("%s: virStreamFree(%p) returned %d (%s)\n", __FUNCTION__, (virStreamPtr)mem, rv, LIBVIRT_G (last_error));
+ php_error_docref(NULL TSRMLS_CC, E_WARNING,"virStreamFree failed with %i on destructor: %s", rv, LIBVIRT_G (last_error));
+ }
+ else {
+ DPRINTF("%s: virStreamFree(%p) completed successfully\n", __FUNCTION__, (virStreamPtr)mem);
+ resource_change_counter(INT_RESOURCE_STREAM, NULL, (virStreamPtr)mem, 0 TSRMLS_CC);
+ }
+ }
+
if (type == INT_RESOURCE_NETWORK) {
rv = virNetworkFree( (virNetworkPtr)mem );
if (rv != 0) {
@@ -986,6 +1011,36 @@ static void php_libvirt_domain_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC)
}
}
+/* Destructor for stream resource */
+static void php_libvirt_stream_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC)
+{
+ php_libvirt_stream *stream = (php_libvirt_stream*)rsrc->ptr;
+ int rv = 0;
+
+ if (stream != NULL)
+ {
+ if (stream->stream != NULL)
+ {
+ if (!check_resource_allocation(NULL, INT_RESOURCE_STREAM, stream->stream TSRMLS_CC)) {
+ stream->stream=NULL;
+ efree (stream);
+ return;
+ }
+ rv = virStreamFree(stream->stream);
+ if (rv != 0) {
+ DPRINTF("%s: virStreamFree(%p) returned %d (%s)\n", __FUNCTION__, stream->stream, rv, LIBVIRT_G (last_error));
+ php_error_docref(NULL TSRMLS_CC, E_WARNING,"virStreamFree failed with %i on destructor: %s", rv, LIBVIRT_G (last_error));
+ }
+ else {
+ DPRINTF("%s: virStreamFree(%p) completed successfully\n", __FUNCTION__, stream->stream);
+ resource_change_counter(INT_RESOURCE_STREAM, NULL, stream->stream, 0 TSRMLS_CC);
+ }
+ stream->stream=NULL;
+ }
+ efree (stream);
+ }
+}
+
/* Destructor for storagepool resource */
static void php_libvirt_storagepool_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC)
{
@@ -1144,6 +1199,7 @@ PHP_MINIT_FUNCTION(libvirt)
/* register resource types and their descriptors */
le_libvirt_connection = zend_register_list_destructors_ex(php_libvirt_connection_dtor, NULL, PHP_LIBVIRT_CONNECTION_RES_NAME, module_number);
le_libvirt_domain = zend_register_list_destructors_ex(php_libvirt_domain_dtor, NULL, PHP_LIBVIRT_DOMAIN_RES_NAME, module_number);
+ le_libvirt_stream = zend_register_list_destructors_ex(php_libvirt_stream_dtor, NULL, PHP_LIBVIRT_STREAM_RES_NAME, module_number);
le_libvirt_storagepool = zend_register_list_destructors_ex(php_libvirt_storagepool_dtor, NULL, PHP_LIBVIRT_STORAGEPOOL_RES_NAME, module_number);
le_libvirt_volume = zend_register_list_destructors_ex(php_libvirt_volume_dtor, NULL, PHP_LIBVIRT_VOLUME_RES_NAME, module_number);
le_libvirt_network = zend_register_list_destructors_ex(php_libvirt_network_dtor, NULL, PHP_LIBVIRT_NETWORK_RES_NAME, module_number);
@@ -1171,6 +1227,11 @@ PHP_MINIT_FUNCTION(libvirt)
REGISTER_LONG_CONSTANT("VIR_DOMAIN_SHUTOFF", 5, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("VIR_DOMAIN_CRASHED", 6, CONST_CS | CONST_PERSISTENT);
+ /* Volume constants */
+ REGISTER_LONG_CONSTANT("VIR_STORAGE_VOL_RESIZE_ALLOCATE", 1, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_STORAGE_VOL_RESIZE_DELTA", 2, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_STORAGE_VOL_RESIZE_SHRINK", 4, CONST_CS | CONST_PERSISTENT);
+
/* Domain vCPU flags */
REGISTER_LONG_CONSTANT("VIR_DOMAIN_VCPU_CONFIG", VIR_DOMAIN_VCPU_CONFIG, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("VIR_DOMAIN_VCPU_CURRENT", VIR_DOMAIN_VCPU_CURRENT, CONST_CS | CONST_PERSISTENT);
@@ -3456,6 +3517,207 @@ PHP_FUNCTION(libvirt_domain_lookup_by_uuid_string)
}
/*
+ Function name: libvirt_stream_create
+ Since version: 0.5.0
+ Description: Function is used to create new stream from libvirt conn
+ Arguments: @res [resource]: libvirt connection resource from libvirt_connect()
+ Returns: resource libvirt stream resource
+*/
+PHP_FUNCTION(libvirt_stream_create)
+{
+ php_libvirt_connection *conn=NULL;
+ zval *zconn;
+ virStreamPtr stream = NULL;
+ php_libvirt_stream *res_stream;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zconn) == FAILURE) {
+ RETURN_FALSE;
+ }
+ ZEND_FETCH_RESOURCE (conn, php_libvirt_connection*, &zconn, -1, PHP_LIBVIRT_CONNECTION_RES_NAME, le_libvirt_connection);
+ if ((conn==NULL)||(conn->conn==NULL))RETURN_FALSE;
+
+ stream = virStreamNew(conn->conn, 0);
+ if (stream==NULL) {
+ set_error("Cannot create new stream" TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ res_stream = (php_libvirt_stream *)emalloc(sizeof(php_libvirt_stream));
+ res_stream->stream = stream;
+ res_stream->conn = conn;
+
+ resource_change_counter(INT_RESOURCE_STREAM, conn->conn, res_stream->stream, 1 TSRMLS_CC);
+ ZEND_REGISTER_RESOURCE(return_value, res_stream, le_libvirt_stream);
+}
+
+/*
+ Function name: libvirt_stream_close
+ Since version: 0.5.0
+ Description: Function is used to close stream
+ Arguments: @res [resource]: libvirt stream resource from libvirt_stream_create()
+ Returns: int
+*/
+PHP_FUNCTION(libvirt_stream_close)
+{
+ zval *zstream;
+ php_libvirt_stream *stream=NULL;
+ int retval = -1;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zstream) == FAILURE) {
+ RETURN_LONG(retval);
+ }
+ ZEND_FETCH_RESOURCE (stream, php_libvirt_stream*, &zstream, -1, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream);
+ if ((stream==NULL)||(stream->stream==NULL))RETURN_LONG(retval);
+
+ retval = virStreamFree(stream->stream);
+ if (retval != 0) {
+ set_error("Cannot free stream" TSRMLS_CC);
+ RETURN_LONG(retval);
+ }
+
+ resource_change_counter(INT_RESOURCE_STREAM, stream->conn, stream->stream, 0 TSRMLS_CC);
+ RETURN_LONG(retval);
+}
+
+/*
+ Function name: libvirt_stream_abort
+ Since version: 0.5.0
+ Description: Function is used to abort transfer
+ Arguments: @res [resource]: libvirt stream resource from libvirt_stream_create()
+ Returns: int
+*/
+PHP_FUNCTION(libvirt_stream_abort)
+{
+ zval *zstream;
+ php_libvirt_stream *stream=NULL;
+ int retval = -1;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zstream) == FAILURE) {
+ RETURN_LONG(retval);
+ }
+ ZEND_FETCH_RESOURCE (stream, php_libvirt_stream*, &zstream, -1, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream);
+ if ((stream==NULL)||(stream->stream==NULL))RETURN_LONG(retval);
+
+ retval = virStreamAbort(stream->stream);
+ if (retval != 0) {
+ set_error("Cannot abort stream" TSRMLS_CC);
+ RETURN_LONG(retval);
+ }
+ RETURN_LONG(retval);
+}
+
+/*
+ Function name: libvirt_stream_finish
+ Since version: 0.5.0
+ Description: Function is used to finish transfer
+ Arguments: @res [resource]: libvirt stream resource from libvirt_stream_create()
+ Returns: int
+*/
+PHP_FUNCTION(libvirt_stream_finish)
+{
+ zval *zstream;
+ php_libvirt_stream *stream=NULL;
+ int retval = -1;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zstream) == FAILURE) {
+ RETURN_LONG(retval);
+ }
+ ZEND_FETCH_RESOURCE (stream, php_libvirt_stream*, &zstream, -1, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream);
+ if ((stream==NULL)||(stream->stream==NULL))RETURN_LONG(retval);
+
+ retval = virStreamFinish(stream->stream);
+ if (retval != 0) {
+ set_error("Cannot finish stream" TSRMLS_CC);
+ RETURN_LONG(retval);
+ }
+ RETURN_LONG(retval);
+}
+
+/*
+ Function name: libvirt_stream_recv
+ Since version: 0.5.0
+ Description: Function is used to close stream from libvirt conn
+ Arguments: @res [resource]: libvirt stream resource from libvirt_stream_create()
+ @data [string]: buffer
+ @len [int]: amout of data to recieve
+ Returns: int
+*/
+PHP_FUNCTION(libvirt_stream_recv)
+{
+ zval *zstream, *zbuf;
+ char *recv_buf;
+ php_libvirt_stream *stream=NULL;
+ int retval = -1;
+ long length = 0;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rz|l", &zstream, &zbuf, &length) == FAILURE) {
+ RETURN_LONG(retval);
+ }
+ ZEND_FETCH_RESOURCE (stream, php_libvirt_stream*, &zstream, -1, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream);
+ if ((stream==NULL)||(stream->stream==NULL))RETURN_LONG(retval);
+
+ recv_buf = emalloc(length + 1);
+ memset(recv_buf, 0, length + 1);
+
+ retval = virStreamRecv(stream->stream, recv_buf, length);
+ if (retval < 0) {
+ efree(recv_buf);
+ zval_dtor(zbuf);
+ Z_TYPE_P(zbuf) = IS_NULL;
+ } else {
+ recv_buf[retval] = '\0';
+ /* Rebuild buffer zval */
+ zval_dtor(zbuf);
+ Z_STRVAL_P(zbuf) = recv_buf;
+ Z_STRLEN_P(zbuf) = retval;
+ Z_TYPE_P(zbuf) = IS_STRING;
+ }
+
+ if (retval == -1) {
+ set_error("Cannot recv from stream" TSRMLS_CC);
+ RETURN_LONG(retval);
+ }
+
+ RETURN_LONG(retval);
+}
+
+/*
+ Function name: libvirt_stream_send
+ Since version: 0.5.0
+ Description: Function is used to close stream from libvirt conn
+ Arguments: @res [resource]: libvirt stream resource from libvirt_stream_create()
+ @data [string]: buffer
+ @length [int]: amout of data to send
+ Returns: int
+*/
+PHP_FUNCTION(libvirt_stream_send)
+{
+ zval *zstream, *zbuf;
+ php_libvirt_stream *stream=NULL;
+ int retval = -1;
+ long length = 0;
+ char *cstr;
+ //int cstrlen;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rz|l", &zstream, &zbuf, &length) == FAILURE) {
+ RETURN_LONG(retval);
+ }
+ ZEND_FETCH_RESOURCE (stream, php_libvirt_stream*, &zstream, -1, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream);
+ if ((stream==NULL)||(stream->stream==NULL))RETURN_LONG(retval);
+
+ cstr = Z_STRVAL_P(zbuf);
+ //cstrlen = Z_STRLEN_P(zbuf);
+
+ retval = virStreamSend(stream->stream, cstr, length);
+ if (retval == -1) {
+ set_error("Cannot send to stream" TSRMLS_CC);
+ RETURN_LONG(retval);
+ }
+
+ RETURN_LONG(retval);
+}
+
+/*
Function name: libvirt_domain_lookup_by_id
Since version: 0.4.1(-1)
Description: Function is used to get domain by it's ID, applicable only to running guests
@@ -3544,13 +3806,12 @@ PHP_FUNCTION(libvirt_domain_get_uuid_string)
@opaque [void *]: used for file descriptor
Returns: write() error code as it's calling write
*/
-
static int streamSink(virStreamPtr st ATTRIBUTE_UNUSED,
const char *bytes, size_t nbytes, void *opaque)
{
- int *fd = (int *)opaque;
+ int *fd = (int *)opaque;
- return write(*fd, bytes, nbytes);
+ return write(*fd, bytes, nbytes);
}
/*
@@ -6782,6 +7043,117 @@ PHP_FUNCTION(libvirt_storagevolume_delete)
}
/*
+ Function name: libvirt_storagevolume_resize
+ Since version: 0.5.0
+ Description: Function is used to resize volume identified by it's resource
+ Arguments: @res [resource]: libvirt storagevolume resource
+ @capacity [int]: capacity for the storage volume
+ @flags [int]: optional flags for the storage volume resize for virStorageVolResize()
+ Returns: int
+*/
+PHP_FUNCTION(libvirt_storagevolume_resize)
+{
+ php_libvirt_volume *volume=NULL;
+ zval *zvolume;
+ long flags = 0;
+ long capacity = 0;
+ int retval = -1;
+
+ GET_VOLUME_FROM_ARGS("rl|l", &zvolume, &capacity, &flags);
+
+ retval = virStorageVolResize(volume->volume, capacity, flags);
+ DPRINTF("%s: virStorageVolResize(%p, %d, %d) returned %d\n", PHPFUNC, volume->volume, (int) capacity, (int) flags, retval);
+ if (retval != 0) {
+ set_error_if_unset("Cannot resize storage volume" TSRMLS_CC);
+ RETURN_LONG(retval);
+ }
+
+ RETURN_LONG(retval);
+}
+
+/*
+ Function name: libvirt_storagevolume_download
+ Since version: 0.5.0
+ Description: Function is used to download volume identified by it's resource
+ Arguments: @res [resource]: libvirt storagevolume resource
+ @stream [resource]: stream to use as output
+ @offset [int]: position to start reading from
+ @length [int] : limit on amount of data to download
+ @flags [int]: optional flags for the storage volume download for virStorageVolDownload()
+ Returns: int
+*/
+PHP_FUNCTION(libvirt_storagevolume_download)
+{
+ php_libvirt_volume *volume=NULL;
+ php_libvirt_stream *stream=NULL;
+ zval *zvolume;
+ zval *zstream;
+ long flags = 0;
+ long offset = 0;
+ long length = 0;
+ int retval = -1;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rr|l|l|l", &zvolume, &zstream, &offset, &length, &flags) == FAILURE) {
+ RETURN_LONG(retval);
+ }
+ ZEND_FETCH_RESOURCE (volume, php_libvirt_volume*, &zvolume, -1, PHP_LIBVIRT_VOLUME_RES_NAME, le_libvirt_volume);
+ if ((volume==NULL)||(volume->volume==NULL))RETURN_LONG(retval);
+ ZEND_FETCH_RESOURCE (stream, php_libvirt_stream*, &zstream, -1, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream);
+ if ((stream==NULL)||(stream->stream==NULL))RETURN_LONG(retval);
+
+ retval = virStorageVolDownload(volume->volume, stream->stream, offset, length, flags);
+ DPRINTF("%s: virStorageVolDownload(%p, %p, %d, %d, %d) returned %d\n", PHPFUNC, volume->volume, stream->stream, (int) offset, (int) length, (int) flags, retval);
+
+ if (retval == -1) {
+ set_error("Cannot download from stream" TSRMLS_CC);
+ RETURN_LONG(retval);
+ }
+
+ RETURN_LONG(retval);
+}
+
+/*
+ Function name: libvirt_storagevolume_upload
+ Since version: 0.5.0
+ Description: Function is used to upload volume identified by it's resource
+ Arguments: @res [resource]: libvirt storagevolume resource
+ @stream [resource]: stream to use as input
+ @offset [int]: position to start writing to
+ @length [int] : limit on amount of data to upload
+ @flags [int]: optional flags for the storage volume upload for virStorageVolUpload()
+ Returns: int
+*/
+PHP_FUNCTION(libvirt_storagevolume_upload)
+{
+ php_libvirt_volume *volume=NULL;
+ php_libvirt_stream *stream=NULL;
+ zval *zvolume;
+ zval *zstream;
+ long flags = 0;
+ long offset = 0;
+ long length = 0;
+ int retval = -1;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rr|l|l|l", &zvolume, &zstream, &offset, &length, &flags) == FAILURE) {
+ RETURN_LONG(retval);
+ }
+ ZEND_FETCH_RESOURCE (volume, php_libvirt_volume*, &zvolume, -1, PHP_LIBVIRT_VOLUME_RES_NAME, le_libvirt_volume);
+ if ((volume==NULL)||(volume->volume==NULL))RETURN_LONG(retval);
+ ZEND_FETCH_RESOURCE (stream, php_libvirt_stream*, &zstream, -1, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream);
+ if ((stream==NULL)||(stream->stream==NULL))RETURN_LONG(retval);
+
+ retval = virStorageVolUpload(volume->volume, stream->stream, offset, length, flags);
+ DPRINTF("%s: virStorageVolUpload(%p, %p, %d, %d, %d) returned %d\n", PHPFUNC, volume->volume, stream->stream, (int) offset, (int) length, (int) flags, retval);
+
+ if (retval == -1) {
+ set_error_if_unset("Cannot upload storage volume" TSRMLS_CC);
+ RETURN_LONG(retval);
+ }
+
+ RETURN_LONG(retval);
+}
+
+/*
Function name: libvirt_storagepool_get_uuid_string
Since version: 0.4.1(-1)
Description: Function is used to get storage pool by UUID string
diff --git a/src/libvirt-php.h b/src/libvirt-php.h
index 450fbea..3bcc682 100644
--- a/src/libvirt-php.h
+++ b/src/libvirt-php.h
@@ -214,6 +214,7 @@ ZEND_END_MODULE_GLOBALS(libvirt)
#define INT_RESOURCE_STORAGEPOOL 0x10
#define INT_RESOURCE_VOLUME 0x20
#define INT_RESOURCE_SNAPSHOT 0x40
+#define INT_RESOURCE_STREAM 0x50
typedef struct tVMDisk {
char *path;
@@ -257,6 +258,11 @@ typedef struct _php_libvirt_connection {
long resource_id;
} php_libvirt_connection;
+typedef struct _php_libvirt_stream {
+ virStreamPtr stream;
+ php_libvirt_connection* conn;
+} php_libvirt_stream;
+
typedef struct _php_libvirt_domain {
virDomainPtr domain;
php_libvirt_connection* conn;
@@ -311,6 +317,7 @@ int gdebug;
#define PHP_LIBVIRT_CONNECTION_RES_NAME "Libvirt connection"
#define PHP_LIBVIRT_DOMAIN_RES_NAME "Libvirt domain"
+#define PHP_LIBVIRT_STREAM_RES_NAME "Libvirt stream"
#define PHP_LIBVIRT_STORAGEPOOL_RES_NAME "Libvirt storagepool"
#define PHP_LIBVIRT_VOLUME_RES_NAME "Libvirt volume"
#define PHP_LIBVIRT_NETWORK_RES_NAME "Libvirt virtual network"
@@ -347,6 +354,13 @@ PHP_FUNCTION(libvirt_node_get_info);
PHP_FUNCTION(libvirt_node_get_cpu_stats);
PHP_FUNCTION(libvirt_node_get_cpu_stats_for_each_cpu);
PHP_FUNCTION(libvirt_node_get_mem_stats);
+/* Stream functions */
+PHP_FUNCTION(libvirt_stream_create);
+PHP_FUNCTION(libvirt_stream_close);
+PHP_FUNCTION(libvirt_stream_abort);
+PHP_FUNCTION(libvirt_stream_finish);
+PHP_FUNCTION(libvirt_stream_recv);
+PHP_FUNCTION(libvirt_stream_send);
/* Domain functions */
PHP_FUNCTION(libvirt_domain_new);
PHP_FUNCTION(libvirt_domain_new_get_vnc);
@@ -427,6 +441,9 @@ PHP_FUNCTION(libvirt_storagevolume_get_xml_desc);
PHP_FUNCTION(libvirt_storagevolume_create_xml);
PHP_FUNCTION(libvirt_storagevolume_create_xml_from);
PHP_FUNCTION(libvirt_storagevolume_delete);
+PHP_FUNCTION(libvirt_storagevolume_download);
+PHP_FUNCTION(libvirt_storagevolume_upload);
+PHP_FUNCTION(libvirt_storagevolume_resize);
PHP_FUNCTION(libvirt_storagepool_get_uuid_string);
PHP_FUNCTION(libvirt_storagepool_get_name);
PHP_FUNCTION(libvirt_storagepool_lookup_by_uuid_string);
--
2.3.3
9 years, 6 months
[libvirt] [PATCH] Ignore bridge template names with multiple printf conversions
by Ján Tomko
For some reason, we allow a bridge name with %d in it, which we replace
with an unsigned integer to form a bridge name that does not yet exist
on the host.
Do not blindly pass it to virAsprintf if it's not the only conversion,
to prevent crashing on input like:
<network>
<name>test</name>
<forward mode='none'/>
<bridge name='virbr%d%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s'/>
</network>
Ignore any template strings that do not have exactly one %d conversion,
like we do in various drivers before calling virNetDevTapCreateInBridgePort.
---
This was added by commit 4c3f3b4
http://libvirt.org/git/?p=libvirt.git;a=commitdiff;h=4c3f3b4
https://www.redhat.com/archives/libvir-list/2009-April/msg00394.html
claiming it worked some time before that
src/network/bridge_driver.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 3b879cd..1c5613a 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -2775,7 +2775,13 @@ networkFindUnusedBridgeName(virNetworkObjListPtr nets,
int ret = -1, id = 0;
char *newname = NULL;
- const char *templ = def->bridge ? def->bridge : "virbr%d";
+ const char *templ = "virbr%d";
+ const char *p;
+
+ if (def->bridge &&
+ (p = strchr(def->bridge, '%')) == strrchr(def->bridge, '%') &&
+ strstr(def->bridge, "%d"))
+ templ = def->bridge;
do {
if (virAsprintf(&newname, templ, id) < 0)
@@ -2809,7 +2815,7 @@ networkFindUnusedBridgeName(virNetworkObjListPtr nets,
/*
* networkValidateBridgeName() - if no bridge name is set, or if the
- * bridge name contains a %d (indicating that this is a template for
+ * bridge name contains a % (indicating that this is a template for
* the actual name) try to set an appropriate bridge name. If a
* bridge name *is* set, make sure it doesn't conflict with any other
* network's bridge name.
@@ -2820,7 +2826,7 @@ networkBridgeNameValidate(virNetworkObjListPtr nets,
{
int ret = -1;
- if (def->bridge && !strstr(def->bridge, "%d")) {
+ if (def->bridge && !strchr(def->bridge, '%')) {
if (virNetworkBridgeInUse(nets, def->bridge, def->name)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("bridge name '%s' already in use."),
--
2.0.5
9 years, 6 months