[libvirt] [PATCH] qemu: add capability probing for block-stream
by Shanzhi Yu
Since block-stream is not supported on qemu-kvm, so libvirt should
post more accurate error info when do blockpull with qemu-kvm but
not "Command 'block-stream' is not found"
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1140981
Signed-off-by: Shanzhi Yu <shyu(a)redhat.com>
---
src/qemu/qemu_capabilities.c | 2 ++
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_driver.c | 13 +++++--------
3 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 81ada48..5674f4f 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -269,6 +269,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
"splash-timeout", /* 175 */
"iothread",
+ "block-stream",
);
@@ -1426,6 +1427,7 @@ struct virQEMUCapsStringFlags virQEMUCapsCommands[] = {
{ "query-spice", QEMU_CAPS_SPICE },
{ "query-kvm", QEMU_CAPS_KVM },
{ "block-commit", QEMU_CAPS_BLOCK_COMMIT },
+ { "block-stream", QEMU_CAPS_BLOCK_STREAM },
{ "query-vnc", QEMU_CAPS_VNC },
{ "drive-mirror", QEMU_CAPS_DRIVE_MIRROR },
{ "blockdev-snapshot-sync", QEMU_CAPS_DISK_SNAPSHOT },
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 0980c00..6701965 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -216,6 +216,7 @@ typedef enum {
QEMU_CAPS_RTC_RESET_REINJECTION = 174, /* rtc-reset-reinjection monitor command */
QEMU_CAPS_SPLASH_TIMEOUT = 175, /* -boot splash-time */
QEMU_CAPS_OBJECT_IOTHREAD = 176, /* -object iothread */
+ QEMU_CAPS_BLOCK_STREAM = 177, /* block-stream */
QEMU_CAPS_LAST, /* this must always be the last item */
} virQEMUCapsFlags;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 73edda3..b38bc91 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -14980,15 +14980,12 @@ qemuDomainBlockJobImpl(virDomainObjPtr vm,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("block jobs not supported with this QEMU binary"));
goto cleanup;
- } else if (base) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("partial block pull not supported with this "
- "QEMU binary"));
- goto cleanup;
- } else if (mode == BLOCK_JOB_PULL && bandwidth) {
+ }
+
+ if (mode == BLOCK_JOB_PULL &&
+ !(virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCK_STREAM))){
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("setting bandwidth at start of block pull not "
- "supported with this QEMU binary"));
+ _("block pull is not supported with this QEMU binary"));
goto cleanup;
}
--
1.8.3.1
10 years
[libvirt] [PATCH] Add support for /run/initctl
by Rick Harris
Newer versions of Debian use `/run/initctl` instead of `/dev/initctl`. This
patch updates the code to search for the FIFO from a list of well-known
locations.
In the FreeBSD case, as before, we fall-back to the `/etc/.initctl` stub.
---
src/util/virinitctl.c | 38 ++++++++++++++++++++++++--------------
1 file changed, 24 insertions(+), 14 deletions(-)
diff --git a/src/util/virinitctl.c b/src/util/virinitctl.c
index a6fda3b..c4b48d4 100644
--- a/src/util/virinitctl.c
+++ b/src/util/virinitctl.c
@@ -46,12 +46,6 @@
* Copyright (C) 1995-2004 Miquel van Smoorenburg
*/
-# if defined(__FreeBSD_kernel__)
-# define VIR_INITCTL_FIFO "/etc/.initctl"
-# else
-# define VIR_INITCTL_FIFO "/dev/initctl"
-# endif
-
# define VIR_INITCTL_MAGIC 0x03091969
# define VIR_INITCTL_CMD_START 0
# define VIR_INITCTL_CMD_RUNLVL 1
@@ -124,6 +118,13 @@ virInitctlSetRunLevel(virInitctlRunLevel level)
struct virInitctlRequest req;
int fd = -1;
int ret = -1;
+ const char *initctl_fifo = NULL;
+ size_t i = 0;
+ const char *initctl_fifos[] = {
+ "/run/initctl",
+ "/dev/initctl",
+ "/etc/.initctl",
+ };
memset(&req, 0, sizeof(req));
@@ -133,22 +134,31 @@ virInitctlSetRunLevel(virInitctlRunLevel level)
/* Yes it is an 'int' field, but wants a numeric character. Go figure */
req.runlevel = '0' + level;
- if ((fd = open(VIR_INITCTL_FIFO,
- O_WRONLY|O_NONBLOCK|O_CLOEXEC|O_NOCTTY)) < 0) {
- if (errno == ENOENT) {
- ret = 0;
+ for (i = 0; i < ARRAY_CARDINALITY(initctl_fifos); i++) {
+ initctl_fifo = initctl_fifos[i];
+
+ if ((fd = open(initctl_fifo,
+ O_WRONLY|O_NONBLOCK|O_CLOEXEC|O_NOCTTY)) >= 0)
+ break;
+
+ if (errno != ENOENT) {
+ virReportSystemError(errno,
+ _("Cannot open init control %s"),
+ initctl_fifo);
goto cleanup;
}
- virReportSystemError(errno,
- _("Cannot open init control %s"),
- VIR_INITCTL_FIFO);
+ }
+
+ /* Ensure we found a valid initctl fifo */
+ if (fd < 0) {
+ ret = 0;
goto cleanup;
}
if (safewrite(fd, &req, sizeof(req)) != sizeof(req)) {
virReportSystemError(errno,
_("Failed to send request to init control %s"),
- VIR_INITCTL_FIFO);
+ initctl_fifo);
goto cleanup;
}
--
1.9.1
10 years
[libvirt] [PATCHv2 0/4] Another attempt at improving virsh autocompletion
by Solly Ross
Version 2: Electric Boogaloo
Version 1: https://www.redhat.com/archives/libvir-list/2014-March/msg01898.html
This version of the patch introduces the following new things:
- Tests (a whole bunch of them, in fact)!
- A new `complete` command to run get newline-separated
completion results from the command line
- Support for completing partial quotes
(e.g. `virsh complete "fake-command ab \"i "`)
- Passing the syntax checks (sorry about that)
A brief overview of the patch set follows:
1. Extract parsing logic from the vshCommandParse
so that it can be used elsewhere. The new method
returns states and sets passed in pointers. Calling
methods can interpret these states and deal with them
as needed (completion ignores many, while
vshCommandParse throws errors).
2. Implement (and test!) an improved completion
engine with support for virsh quoting rules,
flags, positional arguments, no duplication,
and more.
3. Add (and test!) a method for retrieve a global
vshControl object should readline be enabled. This
allows for "smart completion" of options like "domain".
4. Extract the domain listing code from virsh-domain-monitor,
and move it to virsh-completer. Implement a domain completer,
which is then used for all the cases of "domain" options
(note that it current does not have any flags specified for
which commands should list active vs inactive domains,
as this commit is mainly to allow people to test out
"smart completion")
Solly Ross (4):
Improve virsh autocompletion (extract parser)
Improve virsh autocompletion (base framework)
Improve virsh autocompletion (global ctl object)
Improve virsh autocompletion (domain completer)
po/POTFILES.in | 1 +
tests/virshtest.c | 268 +++++++++++++
tools/Makefile.am | 3 +-
tools/virsh-completer.c | 355 +++++++++++++++++
tools/virsh-completer.h | 85 +++++
tools/virsh-domain-monitor.c | 287 +-------------
tools/virsh-domain.c | 72 ++++
tools/virsh-snapshot.c | 11 +
tools/virsh.c | 880 +++++++++++++++++++++++++++++++++++++------
tools/virsh.h | 20 +
10 files changed, 1582 insertions(+), 400 deletions(-)
create mode 100644 tools/virsh-completer.c
create mode 100644 tools/virsh-completer.h
--
1.8.3.2
10 years
[libvirt] [PATCH 0/5] libxl: user-specified domain config improvements
by Jim Fehlig
This is essentially a V2 of Stefan's patch to add support
for user-specified video device in the libxl driver.
https://www.redhat.com/archives/libvir-list/2014-September/msg01157.html
It goes a bit further and adds support for user-specfied <emulator>,
which was trivial to add after introducing libxlDomainGetEmulatorType
in patch 3. To ease review, the series has been split up as follows:
- Missed keymap config from commit 4dfc34c3 split out to patch 1
- Patch 2 added to defer setting default vram value to the Xen drivers
- Patch 3 added to detect old qemu-dm vs qemu with xen support
- Patch 4 is a slightly reworked version of Stefan's patch
- Patch 5 added to support user-specified <emulator>
Jim Fehlig (4):
libxl: Copy user-specified keymap to libxl build info struct
Xen: Defer setting default vram value to Xen drivers
libxl: Add function to determine device model type
libxl: Support user-specified <emulator>
Stefan Bader (1):
libxl: Implement basic video device selection
src/conf/domain_conf.c | 4 ++
src/libxl/libxl_conf.c | 124 +++++++++++++++++++++++++++++++++++++++++++++++
src/libxl/libxl_conf.h | 3 ++
src/libxl/libxl_domain.c | 22 +++++++++
src/xen/xen_driver.c | 19 ++++++++
5 files changed, 172 insertions(+)
--
1.8.4.5
10 years
[libvirt] [PATCH V3 0/3] Some improvements for video model
by Wang Rui
From: Zeng Junliang <zengjunliang(a)huawei.com>
http://www.redhat.com/archives/libvir-list/2014-July/msg00644.html
diff to v2:
- hide vram attribute silently instead of reporting an error.
- introduce three new capabilities for vga.vgamem_mb, vmvga.vgamem_mb and qxl.vgamem_mb.
- fix some error reported by building libvirt.
Zeng Junliang (3):
qemu: Hide vram attribute for some useless cases.
qemu: Introduce vgamem attribute for video model
qemu: Add secondary-vga support
docs/formatdomain.html.in | 46 +++---
docs/schemas/domaincommon.rng | 6 +
src/conf/domain_conf.c | 57 +++++++-
src/conf/domain_conf.h | 3 +
src/libvirt_private.syms | 1 +
src/qemu/qemu_capabilities.c | 17 +++
src/qemu/qemu_capabilities.h | 4 +
src/qemu/qemu_command.c | 162 +++++++++++++++------
src/qemu/qemu_domain.c | 12 ++
tests/qemucapabilitiesdata/caps_1.2.2-1.caps | 3 +
tests/qemucapabilitiesdata/caps_1.3.1-1.caps | 3 +
tests/qemucapabilitiesdata/caps_1.4.2-1.caps | 3 +
tests/qemucapabilitiesdata/caps_1.5.3-1.caps | 3 +
tests/qemucapabilitiesdata/caps_1.6.0-1.caps | 3 +
tests/qemucapabilitiesdata/caps_1.6.50-1.caps | 3 +
tests/qemuhelptest.c | 10 +-
...qemuhotplug-console-compat-2+console-virtio.xml | 2 +-
.../qemuxml2argv-console-compat-2.xml | 2 +-
.../qemuxml2argv-controller-order.xml | 2 +-
.../qemuxml2argv-graphics-listen-network.xml | 2 +-
.../qemuxml2argv-graphics-listen-network2.xml | 2 +-
.../qemuxml2argv-graphics-sdl-fullscreen.xml | 2 +-
.../qemuxml2argvdata/qemuxml2argv-graphics-sdl.xml | 2 +-
...emuxml2argv-graphics-spice-agent-file-xfer.args | 5 +-
...qemuxml2argv-graphics-spice-agent-file-xfer.xml | 4 +-
.../qemuxml2argv-graphics-spice-agentmouse.xml | 2 +-
.../qemuxml2argv-graphics-spice-compression.args | 4 +-
.../qemuxml2argv-graphics-spice-compression.xml | 4 +-
.../qemuxml2argv-graphics-spice-listen-network.xml | 4 +-
.../qemuxml2argv-graphics-spice-qxl-vga.args | 4 +-
.../qemuxml2argv-graphics-spice-qxl-vga.xml | 4 +-
.../qemuxml2argv-graphics-spice-sasl.args | 3 +-
.../qemuxml2argv-graphics-spice-sasl.xml | 2 +-
.../qemuxml2argv-graphics-spice-timeout.xml | 2 +-
.../qemuxml2argv-graphics-spice.args | 5 +-
.../qemuxml2argv-graphics-spice.xml | 4 +-
.../qemuxml2argv-graphics-vnc-policy.xml | 2 +-
.../qemuxml2argv-graphics-vnc-sasl.xml | 2 +-
.../qemuxml2argv-graphics-vnc-secondary-vga.args | 7 +
.../qemuxml2argv-graphics-vnc-secondary-vga.xml | 39 +++++
.../qemuxml2argv-graphics-vnc-socket.xml | 2 +-
.../qemuxml2argv-graphics-vnc-std-vga.args | 4 +
.../qemuxml2argv-graphics-vnc-std-vga.xml | 36 +++++
.../qemuxml2argv-graphics-vnc-tls.xml | 2 +-
.../qemuxml2argv-graphics-vnc-vmware-svga.args | 4 +
.../qemuxml2argv-graphics-vnc-vmware-svga.xml | 36 +++++
.../qemuxml2argv-graphics-vnc-websocket.xml | 2 +-
.../qemuxml2argvdata/qemuxml2argv-graphics-vnc.xml | 2 +-
.../qemuxml2argv-net-bandwidth.xml | 2 +-
.../qemuxml2argv-pci-autoadd-addr.xml | 2 +-
.../qemuxml2argv-pci-autoadd-idx.xml | 2 +-
tests/qemuxml2argvdata/qemuxml2argv-pci-bridge.xml | 2 +-
.../qemuxml2argv-pcihole64-q35.args | 3 +-
.../qemuxml2argv-pcihole64-q35.xml | 2 +-
.../qemuxml2argvdata/qemuxml2argv-pseries-disk.xml | 2 +-
tests/qemuxml2argvdata/qemuxml2argv-q35.args | 3 +-
tests/qemuxml2argvdata/qemuxml2argv-q35.xml | 2 +-
.../qemuxml2argv-serial-spiceport.args | 4 +-
.../qemuxml2argv-serial-spiceport.xml | 2 +-
.../qemuxml2argv-video-device-pciaddr-default.args | 9 +-
.../qemuxml2argv-video-device-pciaddr-default.xml | 6 +-
tests/qemuxml2argvtest.c | 26 +++-
.../qemuxml2xmlout-graphics-listen-network2.xml | 2 +-
.../qemuxml2xmlout-graphics-spice-timeout.xml | 2 +-
.../qemuxml2xmlout-pci-autoadd-addr.xml | 2 +-
.../qemuxml2xmlout-pci-autoadd-idx.xml | 2 +-
tests/qemuxml2xmloutdata/qemuxml2xmlout-q35.xml | 2 +-
tests/qemuxml2xmltest.c | 3 +
68 files changed, 494 insertions(+), 121 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-secondary-vga.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-secondary-vga.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-std-vga.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-std-vga.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-vmware-svga.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-vmware-svga.xml
--
1.7.12.4
10 years
[libvirt] [Question] capabilities.pidfile is left behind while starting and stopping libvirtd repeatly
by Wang Yufei
Hi, all
I started and stopped libvirtd service repeatly with high frequency(1 per second), and found that the file capabilities.pidfile is left behind, as well as a qemu process. If I then restart libvirtd, qemu-kvm will fail to start as it's unable to flock capabilities.pidfile's fd.
Steps to reproduce the problem:
1. start libvirtd service per second with a shell script.
2. meanwhile, stop libvirtd service per second with another shell script.
3. then, a process qemu is left behind:
/usr/bin/qemu-kvm -S -no-user-config -nodefaults -nographic -M none -qmp unix:/var/lib/libvirt/qemu/capabilities.monitor.sock,server,nowait -pidfile /var/lib/libvirt/qemu/capabilities.pidfile -daemonize
4. file /var/lib/libvirt/qemu/capabilities.pidfile is left behind
5. start libvirtd again, the process qemu-kvm fails to start.
The cause of the problem:
This file is generated by qemu, and deleted by libvirtd. If libvirtd got killed before it removes the pidfile, it would be left behind then.
Question:
Would it be fine if I kill qemu-kvm process and unlink capabilities.pidfile, just before virQEMUCapsInitQMP runs this qemu-kvm process?
--
Best Regards
Wang Yufei
10 years
[libvirt] [PATCH v3 0/3] Add support for shared memory devices
by Martin Kletzander
v3:
- removed the dead code for server start attribute
- fixed default path in documentation
- removed unnecessary check for shmem size
v2 is here:
https://www.redhat.com/archives/libvir-list/2014-September/msg01519.html
v1 (Maxime's) is here:
https://www.redhat.com/archives/libvir-list/2014-August/msg01032.html
Martin Kletzander (2):
docs, conf, schema: add support for shmem device
qemu: Build command line for ivshmem device
Maxime Leroy (1):
qemu: add capability probing for ivshmem device
docs/formatdomain.html.in | 52 ++++++
docs/schemas/domaincommon.rng | 39 ++++
src/conf/domain_conf.c | 198 ++++++++++++++++++++-
src/conf/domain_conf.h | 24 +++
src/qemu/qemu_capabilities.c | 2 +
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_command.c | 118 +++++++++++-
src/qemu/qemu_command.h | 1 +
src/qemu/qemu_hotplug.c | 1 +
tests/qemucapabilitiesdata/caps_1.2.2-1.caps | 1 +
tests/qemucapabilitiesdata/caps_1.3.1-1.caps | 1 +
tests/qemucapabilitiesdata/caps_1.4.2-1.caps | 1 +
tests/qemucapabilitiesdata/caps_1.5.3-1.caps | 1 +
tests/qemucapabilitiesdata/caps_1.6.0-1.caps | 1 +
tests/qemucapabilitiesdata/caps_1.6.50-1.caps | 1 +
tests/qemucapabilitiesdata/caps_2.1.1-1.caps | 1 +
tests/qemuhelptest.c | 15 +-
.../qemuxml2argv-shmem-invalid-size.xml | 24 +++
.../qemuxml2argv-shmem-msi-only.xml | 24 +++
.../qemuxml2argv-shmem-small-size.xml | 24 +++
tests/qemuxml2argvdata/qemuxml2argv-shmem.args | 16 ++
tests/qemuxml2argvdata/qemuxml2argv-shmem.xml | 51 ++++++
tests/qemuxml2argvtest.c | 7 +
tests/qemuxml2xmltest.c | 1 +
24 files changed, 598 insertions(+), 7 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-shmem-invalid-size.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-shmem-msi-only.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-shmem-small-size.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-shmem.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-shmem.xml
--
2.1.1
10 years
[libvirt] [PATCH v2] hotplug: Fix libvirtd crash on qemu-attached guest
by John Ferlan
https://bugzilla.redhat.com/show_bug.cgi?id=1141621
The crash in this case was because the qemu-attach code did not create
aliases for qemu cli args. When the detach-interface code was called
it assumed aliases were set resulting in a core when dereferencing the
still NULL alias.
Adding a call to qemuAssignDeviceAliases() resolves the path for
qemu-attach; however, to prevent future issues an additional check
for a NULL value is made and an error provided in the deatch path.
Add some more verbiage to the virsh man page.
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
v1 is here:
http://www.redhat.com/archives/libvir-list/2014-September/msg01331.html
Changes since v1:
- Add the call to qemuAssignDeviceAliases() in qemuDomainQemuAttach().
- Move the check for NULL alias inside the CAPS_DEVICE check and emit
an error rather than trying to remove as an "else" condition.
src/qemu/qemu_driver.c | 3 +++
src/qemu/qemu_hotplug.c | 7 +++++++
tools/virsh.pod | 5 +++--
3 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 117138a..ef4ecd2 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -14746,6 +14746,9 @@ static virDomainPtr qemuDomainQemuAttach(virConnectPtr conn,
if (qemuCanonicalizeMachine(def, qemuCaps) < 0)
goto cleanup;
+ if (qemuAssignDeviceAliases(def, qemuCaps) < 0)
+ goto cleanup;
+
if (qemuDomainAssignAddresses(def, qemuCaps, NULL) < 0)
goto cleanup;
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index d631887..daebe82 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -3521,6 +3521,13 @@ qemuDomainDetachNetDevice(virConnectPtr conn,
qemuDomainObjEnterMonitor(driver, vm);
if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
+ if (!detach->info.alias) {
+ virReportError(VIR_ERR_OPERATION_FAILED, "%s",
+ _("device alias not found: cannot delete the "
+ "net device"));
+ qemuDomainObjExitMonitor(driver, vm);
+ goto cleanup;
+ }
if (qemuMonitorDelDevice(priv->mon, detach->info.alias) < 0) {
qemuDomainObjExitMonitor(driver, vm);
virDomainAuditNet(vm, detach, NULL, "detach", false);
diff --git a/tools/virsh.pod b/tools/virsh.pod
index eae9195..bd17f68 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -3698,8 +3698,9 @@ using the UNIX driver. Ideally the process will also have had the
Not all functions of libvirt are expected to work reliably after
attaching to an externally launched QEMU process. There may be
-issues with the guest ABI changing upon migration, and hotunplug
-may not work.
+issues with the guest ABI changing upon migration and device hotplug
+or hotunplug may not work. The attached environment should be considered
+primarily read-only.
=item B<qemu-monitor-command> I<domain> { [I<--hmp>] | [I<--pretty>] }
I<command>...
--
1.9.3
10 years
[libvirt] Notes: Non-shared storage live migration w/ active blockcommit
by Kashyap Chamarthy
This notes is based on an IRC conversation with Eric Blake, to have
efficient non-shared storage live migration. Thought I'd post my notes
here before I forget. Please review and spot if there are any
inaccuracies.
Procedure
---------
(1) Starting from disk A, create a snapshot A <- A':
$ virsh snapshot-create-as \
--domain f20vm snap1 snap1-desc \
--diskspec hda,file=/export/vmimages/A'.qcow2 \
--disk-only --atomic
(2) Background copy of A to B:
$ virsh blockcopy \
--domain vm1 vda /export/vmimages/B.qcow2 \
--wait --verbose --shallow \
--finish
(3) Create an empty B' with backing file B:
$ qemu-img create -f qcow2 -b B.qcow2 \
-o backing_fmt=qcow2 B'.qcow2
[or]
$ virsh vol-create-as default B'.qcow2 1G \
--format qcow2 \
--backing-vol B.qcow2 --backing-vol-format qcow2
(4) Do a shallow blockcopy of A' to B':
$ virsh blockcopy \
--domain vm1 vda /export/vmimages/B'.qcow2 \
--wait --verbose --shallow \
--finish
(5) Then live shallow commit of B:
$ virsh blockcommit \
--domain f20vm vda \
--wait --verbose --shallow \
--pivot --active --finish
Block Commit: [100 %]
Successfully pivoted
--
/kashyap
10 years
[libvirt] [PATCH-RFC-V2] qemu: Add network bandwidth setting for ethernet interfaces
by Anirban Chakraborty
V2:
Consolidate calls to virNetDevBandwidthSet
Clear bandwidth settings when the interface is detached or domain destroyed
V1:
Ethernet interfaces in libvirt currently do not support bandwidth setting.
For example, following xml file for an interface will not apply these
settings to corresponding qdiscs.
<interface type="ethernet">
<mac address="02:36:1d:18:2a:e4"/>
<model type="virtio"/>
<script path=""/>
<target dev="tap361d182a-e4"/>
<bandwidth>
<inbound average="984" peak="1024" burst="64"/>
<outbound average="2000" peak="2048" burst="128"/>
</bandwidth>
</interface>
Signed-off-by: Anirban Chakraborty <abchak(a)juniper.net>
---
src/conf/domain_conf.h | 7 +++++++
src/lxc/lxc_process.c | 27 ++++++++++++++-------------
src/qemu/qemu_command.c | 9 ++++-----
src/qemu/qemu_driver.c | 21 +++++++++++++++++++++
src/qemu/qemu_hotplug.c | 13 +++++++++++++
src/util/virnetdevmacvlan.c | 10 ----------
src/util/virnetdevmacvlan.h | 1 -
7 files changed, 59 insertions(+), 29 deletions(-)
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 640a4c5..3c950f1 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -829,6 +829,13 @@ typedef enum {
VIR_DOMAIN_NET_TYPE_LAST
} virDomainNetType;
+/* check bandwidth configuration for a network interface */
+#define NETDEVIF_SUPPORT_BANDWIDTH(type) \
+ ((type == VIR_DOMAIN_NET_TYPE_ETHERNET || \
+ type == VIR_DOMAIN_NET_TYPE_NETWORK || \
+ type == VIR_DOMAIN_NET_TYPE_BRIDGE || \
+ type == VIR_DOMAIN_NET_TYPE_DIRECT) ? true : false)
+
/* the backend driver used for virtio interfaces */
typedef enum {
VIR_DOMAIN_NET_BACKEND_TYPE_DEFAULT, /* prefer kernel, fall back to user */
diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c
index ed30c37..5ef91e8 100644
--- a/src/lxc/lxc_process.c
+++ b/src/lxc/lxc_process.c
@@ -274,11 +274,6 @@ char *virLXCProcessSetupInterfaceBridged(virConnectPtr conn,
if (virNetDevSetOnline(parentVeth, true) < 0)
goto cleanup;
- if (virNetDevBandwidthSet(net->ifname,
- virDomainNetGetActualBandwidth(net),
- false) < 0)
- goto cleanup;
-
if (net->filter &&
virDomainConfNWFilterInstantiate(conn, vm->uuid, net) < 0)
goto cleanup;
@@ -300,6 +295,7 @@ char *virLXCProcessSetupInterfaceDirect(virConnectPtr conn,
virNetDevBandwidthPtr bw;
virNetDevVPortProfilePtr prof;
virLXCDriverConfigPtr cfg = virLXCDriverGetConfig(driver);
+ const char *linkdev = virDomainNetGetActualDirectDev(net);
/* XXX how todo bandwidth controls ?
* Since the 'net-ifname' is about to be moved to a different
@@ -329,16 +325,15 @@ char *virLXCProcessSetupInterfaceDirect(virConnectPtr conn,
if (virNetDevMacVLanCreateWithVPortProfile(
net->ifname, &net->mac,
- virDomainNetGetActualDirectDev(net),
+ linkdev,
virDomainNetGetActualDirectMode(net),
false, def->uuid,
- virDomainNetGetActualVirtPortProfile(net),
+ prof,
&res_ifname,
VIR_NETDEV_VPORT_PROFILE_OP_CREATE,
cfg->stateDir,
- virDomainNetGetActualBandwidth(net), 0) < 0)
+ 0) < 0)
goto cleanup;
-
ret = res_ifname;
cleanup:
@@ -368,6 +363,7 @@ static int virLXCProcessSetupInterfaces(virConnectPtr conn,
int ret = -1;
size_t i;
size_t niface = 0;
+ int actualType;
for (i = 0; i < def->nnets; i++) {
char *veth = NULL;
@@ -381,7 +377,8 @@ static int virLXCProcessSetupInterfaces(virConnectPtr conn,
if (VIR_EXPAND_N(*veths, *nveths, 1) < 0)
goto cleanup;
- switch (virDomainNetGetActualType(def->nets[i])) {
+ actualType = virDomainNetGetActualType(def->nets[i]);
+ switch (actualType) {
case VIR_DOMAIN_NET_TYPE_NETWORK: {
virNetworkPtr network;
char *brname = NULL;
@@ -444,11 +441,15 @@ static int virLXCProcessSetupInterfaces(virConnectPtr conn,
case VIR_DOMAIN_NET_TYPE_LAST:
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unsupported network type %s"),
- virDomainNetTypeToString(
- virDomainNetGetActualType(def->nets[i])
- ));
+ virDomainNetTypeToString(actualType));
goto cleanup;
}
+ /* set network bandwidth */
+ if (NETDEVIF_SUPPORT_BANDWIDTH(actualType) && virNetDevBandwidthSet(
+ def->nets[i]->ifname, virDomainNetGetActualBandwidth(
+ def->nets[i]),
+ false) < 0)
+ goto cleanup;
(*veths)[(*nveths)-1] = veth;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index f2e6e5a..404c51b 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -191,7 +191,6 @@ qemuPhysIfaceConnect(virDomainDefPtr def,
virDomainNetGetActualVirtPortProfile(net),
&res_ifname,
vmop, cfg->stateDir,
- virDomainNetGetActualBandwidth(net),
macvlan_create_flags);
if (rc >= 0) {
virDomainAuditNetDevice(def, net, res_ifname, true);
@@ -371,10 +370,6 @@ qemuNetworkIfaceConnect(virDomainDefPtr def,
&net->mac) < 0)
goto cleanup;
- if (virNetDevBandwidthSet(net->ifname,
- virDomainNetGetActualBandwidth(net),
- false) < 0)
- goto cleanup;
if (net->filter &&
virDomainConfNWFilterInstantiate(conn, def->uuid, net) < 0) {
@@ -7313,6 +7308,10 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd,
if (tapfd[0] < 0)
goto cleanup;
}
+ /* Set bandwidth */
+ if (NETDEVIF_SUPPORT_BANDWIDTH(actualType) && virNetDevBandwidthSet(
+ net->ifname, virDomainNetGetActualBandwidth(net), false) < 0)
+ goto cleanup;
if ((actualType == VIR_DOMAIN_NET_TYPE_NETWORK ||
actualType == VIR_DOMAIN_NET_TYPE_BRIDGE ||
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 5fd89a3..f5a5cbe 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -186,6 +186,9 @@ qemuVMFilterRebuild(virDomainObjListIterator iter, void *data)
return virDomainObjListForEach(qemu_driver->domains, iter, data);
}
+static void
+qemuDomainClearNetBandwidth(virDomainObjPtr vm);
+
static virNWFilterCallbackDriver qemuCallbackDriver = {
.name = QEMU_DRIVER_NAME,
.vmFilterRebuild = qemuVMFilterRebuild,
@@ -2196,6 +2199,9 @@ qemuDomainDestroyFlags(virDomainPtr dom,
if (virDomainDestroyFlagsEnsureACL(dom->conn, vm->def) < 0)
goto cleanup;
+ /* Clear network bandwidth settings */
+ qemuDomainClearNetBandwidth(vm);
+
qemuDomainSetFakeReboot(driver, vm, false);
@@ -17952,6 +17958,21 @@ qemuConnectGetAllDomainStats(virConnectPtr conn,
return ret;
}
+/* Clear the bandwidth setting of all the network interfaces of a vm */
+static void
+qemuDomainClearNetBandwidth(virDomainObjPtr vm)
+{
+ size_t i;
+ int actualType;
+
+ for (i = 0; i < vm->def->nnets; i++) {
+ virDomainNetDefPtr net = vm->def->nets[i];
+ actualType = virDomainNetGetActualType(net);
+ if (NETDEVIF_SUPPORT_BANDWIDTH(actualType))
+ virNetDevBandwidthClear(net->ifname);
+ }
+}
+
static virDriver qemuDriver = {
.no = VIR_DRV_QEMU,
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 7bc19cd..acf48af 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -947,6 +947,10 @@ int qemuDomainAttachNetDevice(virConnectPtr conn,
if (qemuOpenVhostNet(vm->def, net, priv->qemuCaps, vhostfd, &vhostfdSize) < 0)
goto cleanup;
}
+ /* Set bandwidth */
+ if (NETDEVIF_SUPPORT_BANDWIDTH(actualType) && virNetDevBandwidthSet(net->ifname,
+ virDomainNetGetActualBandwidth(net), false) < 0)
+ goto cleanup;
for (i = 0; i < tapfdSize; i++) {
if (virSecurityManagerSetTapFDLabel(driver->securityManager,
@@ -3481,6 +3485,7 @@ qemuDomainDetachNetDevice(virConnectPtr conn,
virDomainNetDefPtr detach = NULL;
qemuDomainObjPrivatePtr priv = vm->privateData;
int rc;
+ int actualType;
if ((detachidx = virDomainNetFindIdx(vm->def, dev->data.net)) < 0)
goto cleanup;
@@ -3517,6 +3522,14 @@ qemuDomainDetachNetDevice(virConnectPtr conn,
}
}
+ actualType = virDomainNetGetActualType(detach);
+ if (NETDEVIF_SUPPORT_BANDWIDTH(actualType) &&
+ (virNetDevBandwidthClear(detach->ifname) < 0)) {
+ virReportError(VIR_ERR_OPERATION_FAILED,
+ _("cannot clear bandwidth setting for device : %s"),
+ detach->ifname);
+ goto cleanup;
+ }
qemuDomainMarkDeviceForRemoval(vm, &detach->info);
qemuDomainObjEnterMonitor(driver, vm);
diff --git a/src/util/virnetdevmacvlan.c b/src/util/virnetdevmacvlan.c
index c83341c..956a96b 100644
--- a/src/util/virnetdevmacvlan.c
+++ b/src/util/virnetdevmacvlan.c
@@ -811,7 +811,6 @@ int virNetDevMacVLanCreateWithVPortProfile(const char *tgifname,
char **res_ifname,
virNetDevVPortProfileOp vmOp,
char *stateDir,
- virNetDevBandwidthPtr bandwidth,
unsigned int flags)
{
const char *type = (flags & VIR_NETDEV_MACVLAN_CREATE_WITH_TAP) ?
@@ -925,14 +924,6 @@ int virNetDevMacVLanCreateWithVPortProfile(const char *tgifname,
rc = 0;
}
- if (virNetDevBandwidthSet(cr_ifname, bandwidth, false) < 0) {
- if (flags & VIR_NETDEV_MACVLAN_CREATE_WITH_TAP)
- VIR_FORCE_CLOSE(rc); /* sets rc to -1 */
- else
- rc = -1;
- goto disassociate_exit;
- }
-
if (vmOp == VIR_NETDEV_VPORT_PROFILE_OP_CREATE ||
vmOp == VIR_NETDEV_VPORT_PROFILE_OP_RESTORE) {
/* Only directly register upon a create or restore (restarting
@@ -1076,7 +1067,6 @@ int virNetDevMacVLanCreateWithVPortProfile(const char *ifname ATTRIBUTE_UNUSED,
char **res_ifname ATTRIBUTE_UNUSED,
virNetDevVPortProfileOp vmop ATTRIBUTE_UNUSED,
char *stateDir ATTRIBUTE_UNUSED,
- virNetDevBandwidthPtr bandwidth ATTRIBUTE_UNUSED,
unsigned int flags)
{
virCheckFlags(0, -1);
diff --git a/src/util/virnetdevmacvlan.h b/src/util/virnetdevmacvlan.h
index 41aa4e2..f08d32b 100644
--- a/src/util/virnetdevmacvlan.h
+++ b/src/util/virnetdevmacvlan.h
@@ -68,7 +68,6 @@ int virNetDevMacVLanCreateWithVPortProfile(const char *ifname,
char **res_ifname,
virNetDevVPortProfileOp vmop,
char *stateDir,
- virNetDevBandwidthPtr bandwidth,
unsigned int flags)
ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(6)
ATTRIBUTE_NONNULL(8) ATTRIBUTE_NONNULL(10) ATTRIBUTE_RETURN_CHECK;
--
1.9.1
10 years