[libvirt] if you use user namespaces
by Serge E. Hallyn
Please let me know. lxc does not use them right now. Libvirt uses them
for lxc containers f they are available, but I hope we can essentially
have it stop for awhile. In addition, there's tons of software out
there that I don't know about, and fear of breaking their use of current
user namespaces has been keeping me from pushing further userns patches.
I've outlined how I see user namespaces developing at
https://wiki.ubuntu.com/UserNamespace . Note there is nothing new
in there - some of it goes a year back, much of it more than two
years. Nothing actually new.
Currently user namespaces are not very useful, but they do provide
separate uid accounting, and simply tossing CLONE_NEWUSER in with
CLONE_NEWNS and friends has until now been safe to do. As you can
see, that is going to change. So if that would cause you pain that
you can't work around, please get back to me. Otherwise, I'd like
to get serious soon about expanding upon, and pushing upstream, the
patches to make CLONE_NEWUSER more useful for sandboxing.
thanks,
-serge
13 years, 8 months
[libvirt] Live migration using virsh
by rajalakshmi
Sir,
I am working in cloud environment and i have set up a private cloud using
eucalyptus. I am trying to migrate virtual machines within the cloud using
virsh migrate command. I could successfully implement it but when i wanted
to know the method used to do live migration. I tried to interpret the code.
I also saw that they are setting a flag initially if it is live migration
and then assigning 1 to variable live. and i also could find that
xenDomainMigratePrepare is calling xend_op which in turn is calling
xend_op_ext. But i could'n understand the method of migration. Can you
please explain the logic?
13 years, 8 months
[libvirt] Vietnamese Translation for libvirt
by Hero Phương
Dear LibVirt team,
I am Phuong, one of Ubuntu Vietnamese Translation team's members. I have
translated your package into my native language. I'm going to send the .po
file to launchpad and I also would like to send one to your team.
I'm looking forward to hearing from all you soon.
Regards,
HeroP
13 years, 8 months
[libvirt] [PATCHv5 6/9] spicevmc: support new qemu chardev
by Eric Blake
From: Daniel P. Berrange <berrange(a)redhat.com>
Inspired by https://bugzilla.redhat.com/show_bug.cgi?id=615757
Add a new character device backend for virtio serial channels that
activates the QEMU spice agent on the main channel using the vdagent
spicevmc connection. The <target> must be type='virtio', and supports
an optional name that specifies how the guest will see the channel
(for now, name must be com.redhat.spice.0).
<channel type='spicevmc'>
<target type='virtio'/>
<address type='virtio-serial' controller='1' bus='0' port='3'/>
</channel>
* docs/schemas/domain.rng: Support new XML.
* docs/formatdomain.html.in: Document it.
* src/conf/domain_conf.h (virDomainChrType): New enum value.
* src/conf/domain_conf.c (virDomainChr): Add spicevmc.
(virDomainChrDefParseXML, virDomainChrSourceDefParseXML)
(virDomainChrDefParseTargetXML): Parse and enforce proper use.
(virDomainChrSourceDefFormat, virDomainChrDefFormat): Format.
* src/qemu/qemu_command.c (qemuBuildChrChardevStr)
(qemuBuildCommandLine): Add qemu support.
* tests/qemuxml2argvtest.c (domain): New test.
* tests/qemuxml2argvdata/qemuxml2argv-channel-spicevmc.xml: New
file.
* tests/qemuxml2argvdata/qemuxml2argv-channel-spicevmc.args:
Likewise.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
Notes:
v5: new patch, but heavily ported from RHEL 6.0
docs/formatdomain.html.in | 17 +++++++
docs/schemas/domain.rng | 3 +-
src/conf/domain_conf.c | 18 +++++++-
src/conf/domain_conf.h | 2 +
src/qemu/qemu_command.c | 47 ++++++++++++++++---
.../qemuxml2argv-channel-spicevmc.args | 9 ++++
.../qemuxml2argv-channel-spicevmc.xml | 34 ++++++++++++++
tests/qemuxml2argvtest.c | 3 +
8 files changed, 123 insertions(+), 10 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-channel-spicevmc.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-channel-spicevmc.xml
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 9f1bb5f..d91fdb9 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -1734,6 +1734,9 @@ qemu-kvm -net nic,model=? /dev/null
<channel type='pty'>
<target type='virtio' name='arbitrary.virtio.serial.port.name'/>
</channel>
+ <channel type='spicevmc'>
+ <target type='virtio' name='com.redhat.spice.0'/>
+ </channel>
</devices>
...</pre>
@@ -1759,6 +1762,20 @@ qemu-kvm -net nic,model=? /dev/null
optional element <code>address</code> can tie the channel to a
particular <code>type='virtio-serial'</code> controller.
<span class="since">Since 0.7.7</span></dd>
+
+ <dt><code>spicevmc</code></dt>
+ <dd>Paravirtualized SPICE channel. The domain must also have a
+ SPICE server as a <a href="#elementsGraphics">graphics
+ device</a>, at which point the host piggy-backs messages
+ across the <code>main</code> channel. The <code>target</code>
+ element must be present, with
+ attribute <code>type='virtio'</code>; an optional
+ attribute <code>name</code> controls how the guest will have
+ access to the channel, and defaults
+ to <code>name='com.redhat.spice.0'</code>. The
+ optional <code>address</code> element can tie the channel to a
+ particular <code>type='virtio-serial'</code> controller.
+ <span class="since">Since 0.8.8</span></dd>
</dl>
<h5><a name="elementsCharHostInterface">Host interface</a></h5>
diff --git a/docs/schemas/domain.rng b/docs/schemas/domain.rng
index 69fb432..9ffcf21 100644
--- a/docs/schemas/domain.rng
+++ b/docs/schemas/domain.rng
@@ -1475,6 +1475,7 @@
<value>stdio</value>
<value>vc</value>
<value>pty</value>
+ <value>spicevmc</value>
</choice>
</attribute>
</define>
@@ -1611,7 +1612,7 @@
<define name="virtioTarget">
<element name="target">
<attribute name="type">
- <value>virtio</value>
+ <value>virtio</value>
</attribute>
<optional>
<attribute name="name"/>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index b1c775b..9b4ef8d 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -226,7 +226,8 @@ VIR_ENUM_IMPL(virDomainChr, VIR_DOMAIN_CHR_TYPE_LAST,
"stdio",
"udp",
"tcp",
- "unix")
+ "unix",
+ "spicevmc")
VIR_ENUM_IMPL(virDomainChrTcpProtocol, VIR_DOMAIN_CHR_TCP_PROTOCOL_LAST,
"raw",
@@ -3065,6 +3066,7 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDefPtr def,
break;
case VIR_DOMAIN_CHR_TYPE_STDIO:
+ case VIR_DOMAIN_CHR_TYPE_SPICEVMC:
/* Nada */
break;
@@ -3254,6 +3256,13 @@ virDomainChrDefParseXML(virCapsPtr caps,
}
}
+ if (def->source.type == VIR_DOMAIN_CHR_TYPE_SPICEVMC &&
+ def->targetType != VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO) {
+ virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("spicevmc device type only supports virtio"));
+ goto error;
+ }
+
if (virDomainDeviceInfoParseXML(node, &def->info, flags) < 0)
goto error;
@@ -3361,6 +3370,12 @@ virDomainSmartcardDefParseXML(xmlNodePtr node,
cur = node->children;
if (virDomainChrSourceDefParseXML(&def->data.passthru, cur) < 0)
goto error;
+
+ if (def->data.passthru.type == VIR_DOMAIN_CHR_TYPE_SPICEVMC) {
+ virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("smartcard spicevmc device not supported"));
+ goto error;
+ }
break;
default:
@@ -6843,6 +6858,7 @@ virDomainChrSourceDefFormat(virBufferPtr buf,
case VIR_DOMAIN_CHR_TYPE_NULL:
case VIR_DOMAIN_CHR_TYPE_VC:
case VIR_DOMAIN_CHR_TYPE_STDIO:
+ case VIR_DOMAIN_CHR_TYPE_SPICEVMC:
/* nada */
break;
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 81c3f38..9dff580 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -413,6 +413,7 @@ enum virDomainChrType {
VIR_DOMAIN_CHR_TYPE_UDP,
VIR_DOMAIN_CHR_TYPE_TCP,
VIR_DOMAIN_CHR_TYPE_UNIX,
+ VIR_DOMAIN_CHR_TYPE_SPICEVMC,
VIR_DOMAIN_CHR_TYPE_LAST,
};
@@ -432,6 +433,7 @@ typedef virDomainChrSourceDef *virDomainChrSourceDefPtr;
struct _virDomainChrSourceDef {
int type; /* virDomainChrType */
union {
+ /* no <source> for null, vc, stdio, spicevmc */
struct {
char *path;
} file; /* pty, file, pipe, or device */
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 40d92f4..1903c70 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -2006,7 +2006,8 @@ qemuBuildUSBHostdevUsbDevStr(virDomainHostdevDefPtr dev)
/* This function outputs a -chardev command line option which describes only the
* host side of the character device */
static char *
-qemuBuildChrChardevStr(virDomainChrSourceDefPtr dev, const char *alias)
+qemuBuildChrChardevStr(virDomainChrSourceDefPtr dev, const char *alias,
+ unsigned long long qemuCmdFlags)
{
virBuffer buf = VIR_BUFFER_INITIALIZER;
bool telnet;
@@ -2072,6 +2073,21 @@ qemuBuildChrChardevStr(virDomainChrSourceDefPtr dev, const char *alias)
dev->data.nix.path,
dev->data.nix.listen ? ",server,nowait" : "");
break;
+
+ case VIR_DOMAIN_CHR_TYPE_SPICEVMC:
+ if (!(qemuCmdFlags & QEMUD_CMD_FLAG_CHARDEV_SPICEVMC)) {
+ qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("spicevmc not supported in this QEMU binary"));
+ goto error;
+ }
+ virBufferVSprintf(&buf, "spicevmc,id=char%s,name=vdagent", alias);
+ break;
+
+ default:
+ qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("unsupported chardev '%s'"),
+ virDomainChrTypeToString(dev->type));
+ goto error;
}
if (virBufferError(&buf)) {
@@ -2196,6 +2212,14 @@ qemuBuildVirtioSerialPortDevStr(virDomainChrDefPtr dev)
virBufferVSprintf(&buf, ",chardev=char%s,id=%s",
dev->info.alias, dev->info.alias);
+ if (dev->source.type == VIR_DOMAIN_CHR_TYPE_SPICEVMC &&
+ dev->target.name &&
+ STRNEQ(dev->target.name, "com.redhat.spice.0")) {
+ qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("Unsupported spicevmc target name '%s'"),
+ dev->target.name);
+ goto error;
+ }
if (dev->target.name) {
virBufferVSprintf(&buf, ",name=%s", dev->target.name);
}
@@ -2825,7 +2849,8 @@ qemuBuildCommandLine(virConnectPtr conn,
if (qemuCmdFlags & QEMUD_CMD_FLAG_CHARDEV) {
virCommandAddArg(cmd, "-chardev");
- if (!(chrdev = qemuBuildChrChardevStr(monitor_chr, "monitor")))
+ if (!(chrdev = qemuBuildChrChardevStr(monitor_chr, "monitor",
+ qemuCmdFlags)))
goto error;
virCommandAddArg(cmd, chrdev);
VIR_FREE(chrdev);
@@ -3523,7 +3548,8 @@ qemuBuildCommandLine(virConnectPtr conn,
virCommandAddArg(cmd, "-chardev");
if (!(devstr = qemuBuildChrChardevStr(&smartcard->data.passthru,
- smartcard->info.alias))) {
+ smartcard->info.alias,
+ qemuCmdFlags))) {
virBufferFreeAndReset(&opt);
goto error;
}
@@ -3560,7 +3586,8 @@ qemuBuildCommandLine(virConnectPtr conn,
(qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE)) {
virCommandAddArg(cmd, "-chardev");
if (!(devstr = qemuBuildChrChardevStr(&serial->source,
- serial->info.alias)))
+ serial->info.alias,
+ qemuCmdFlags)))
goto error;
virCommandAddArg(cmd, devstr);
VIR_FREE(devstr);
@@ -3592,7 +3619,8 @@ qemuBuildCommandLine(virConnectPtr conn,
(qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE)) {
virCommandAddArg(cmd, "-chardev");
if (!(devstr = qemuBuildChrChardevStr(¶llel->source,
- parallel->info.alias)))
+ parallel->info.alias,
+ qemuCmdFlags)))
goto error;
virCommandAddArg(cmd, devstr);
VIR_FREE(devstr);
@@ -3626,7 +3654,8 @@ qemuBuildCommandLine(virConnectPtr conn,
virCommandAddArg(cmd, "-chardev");
if (!(devstr = qemuBuildChrChardevStr(&channel->source,
- channel->info.alias)))
+ channel->info.alias,
+ qemuCmdFlags)))
goto error;
virCommandAddArg(cmd, devstr);
VIR_FREE(devstr);
@@ -3653,7 +3682,8 @@ qemuBuildCommandLine(virConnectPtr conn,
virCommandAddArg(cmd, "-chardev");
if (!(devstr = qemuBuildChrChardevStr(&channel->source,
- channel->info.alias)))
+ channel->info.alias,
+ qemuCmdFlags)))
goto error;
virCommandAddArg(cmd, devstr);
VIR_FREE(devstr);
@@ -3682,7 +3712,8 @@ qemuBuildCommandLine(virConnectPtr conn,
virCommandAddArg(cmd, "-chardev");
if (!(devstr = qemuBuildChrChardevStr(&console->source,
- console->info.alias)))
+ console->info.alias,
+ qemuCmdFlags)))
goto error;
virCommandAddArg(cmd, devstr);
VIR_FREE(devstr);
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-channel-spicevmc.args b/tests/qemuxml2argvdata/qemuxml2argv-channel-spicevmc.args
new file mode 100644
index 0000000..681f7c2
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-channel-spicevmc.args
@@ -0,0 +1,9 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=spice \
+/usr/bin/qemu -S -M pc -m 214 -smp 1 -nodefconfig -nodefaults \
+-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -device \
+virtio-serial-pci,id=virtio-serial1,bus=pci.0,addr=0xa -hda \
+/dev/HostVG/QEMUGuest1 -chardev spicevmc,id=charchannel0,name=vdagent -device \
+virtserialport,bus=virtio-serial1.0,nr=3,chardev=charchannel0,id=channel0\
+,name=com.redhat.spice.0 -usb -spice port=5903,tls-port=5904,addr=127.0.0.1,\
+x509-dir=/etc/pki/libvirt-spice,tls-channel=main -device \
+virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-channel-spicevmc.xml b/tests/qemuxml2argvdata/qemuxml2argv-channel-spicevmc.xml
new file mode 100644
index 0000000..0e82394
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-channel-spicevmc.xml
@@ -0,0 +1,34 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory>219136</memory>
+ <vcpu cpuset='1-4,8-20,525'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu</emulator>
+ <disk type='block' device='disk'>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0' unit='0'/>
+ </disk>
+ <controller type='ide' index='0'/>
+ <controller type='virtio-serial' index='1'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
+ </controller>
+ <graphics type='spice' port='5903' tlsPort='5904' autoport='no' listen='127.0.0.1'>
+ <channel name='main' mode='secure'/>
+ </graphics>
+ <channel type='spicevmc'>
+ <target type='virtio' name='com.redhat.spice.0'/>
+ <address type='virtio-serial' controller='1' bus='0' port='3'/>
+ </channel>
+ <memballoon model='virtio'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 0b4bfeb..0726130 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -407,6 +407,9 @@ mymain(int argc, char **argv)
QEMUD_CMD_FLAG_NODEFCONFIG, false);
DO_TEST("console-virtio", QEMUD_CMD_FLAG_DEVICE |
QEMUD_CMD_FLAG_NODEFCONFIG, false);
+ DO_TEST("channel-spicevmc", QEMUD_CMD_FLAG_DEVICE |
+ QEMUD_CMD_FLAG_NODEFCONFIG | QEMUD_CMD_FLAG_SPICE |
+ QEMUD_CMD_FLAG_CHARDEV_SPICEVMC, false);
DO_TEST("smartcard-host",
QEMUD_CMD_FLAG_CHARDEV | QEMUD_CMD_FLAG_DEVICE |
--
1.7.4
13 years, 8 months
[libvirt] [PATCHv5 0/9] smartcard round 5
by Eric Blake
Next round. The first 5 patches were previously ack'd in round 4:
https://www.redhat.com/archives/libvir-list/2011-February/msg00026.html
However, I heavily rewrote patch 3 to support later spicevmc patches,
as well as tweaked patch 1 and 5 to avoid the need for memory rounding.
Patch 6 is mostly a port of a patch that has already seen use in RHEL
6.0 which adds the use of -chardev spicevmc,name=vdagent as a means of
communicating with the guest using messages across the main SPICE
graphics channel, but tweaked to be a bit more robust.
Patch 7 was an experiment to add a new vdagent channel type instead of
reusing virtio for the spicevmc channel; I think it failed, but wanted
to at least post it in case I was on the right track after all. Patch
8 undoes 7. It won't hurt my feelings if you skip those.
Patch 9 therefore immediately follows patch 6, and marries the two
concepts to create a smartcard passthrough device that uses a new
smartcard channel of the SPICE server.
Again, this entire series depends on a feature that has been proposed
for upstream qemu, but not accepted yet; while it has probably
stabilized to some degree, it may have minor tweaks. Conversely,
I feel that the XML representation (the most important part to get
right, since it becomes our API contract) is accurate and flexible
enough to cover whatever minor modifiations qemu throws at us as
followup patches to qemu_command.c.
Daniel P. Berrange (1):
spicevmc: support new qemu chardev
Eric Blake (8):
smartcard: add XML support for <smartcard> device
smartcard: add domain conf support
smartcard: check for qemu capability
smartcard: enable SELinux support
smartcard: turn on qemu support
RFC: spicevmc: call out vdagent as a channel target
Revert "RFC: spicevmc: call out vdagent as a channel target"
smartcard: add spicevmc support
cfg.mk | 1 +
docs/formatdomain.html.in | 120 ++++++-
docs/schemas/domain.rng | 70 ++++-
src/conf/domain_conf.c | 395 +++++++++++++++++++-
src/conf/domain_conf.h | 64 +++-
src/libvirt_private.syms | 6 +
src/qemu/qemu_capabilities.c | 17 +-
src/qemu/qemu_capabilities.h | 3 +
src/qemu/qemu_command.c | 154 +++++++-
src/security/security_selinux.c | 76 ++++
tests/qemuhelpdata/qemu-kvm-0.12.1.2-rhel61 | 229 +++++++++++
tests/qemuhelpdata/qemu-kvm-0.12.1.2-rhel61-device | 74 ++++
tests/qemuhelptest.c | 43 +++
.../qemuxml2argv-channel-spicevmc.args | 9 +
.../qemuxml2argv-channel-spicevmc.xml | 34 ++
.../qemuxml2argv-smartcard-controller.args | 7 +
.../qemuxml2argv-smartcard-controller.xml | 19 +
.../qemuxml2argv-smartcard-host-certificates.args | 8 +
.../qemuxml2argv-smartcard-host-certificates.xml | 20 +
.../qemuxml2argv-smartcard-host.args | 7 +
.../qemuxml2argv-smartcard-host.xml | 16 +
...emuxml2argv-smartcard-passthrough-spicevmc.args | 7 +
...qemuxml2argv-smartcard-passthrough-spicevmc.xml | 16 +
.../qemuxml2argv-smartcard-passthrough-tcp.args | 8 +
.../qemuxml2argv-smartcard-passthrough-tcp.xml | 19 +
tests/qemuxml2argvtest.c | 20 +
26 files changed, 1410 insertions(+), 32 deletions(-)
create mode 100644 tests/qemuhelpdata/qemu-kvm-0.12.1.2-rhel61
create mode 100644 tests/qemuhelpdata/qemu-kvm-0.12.1.2-rhel61-device
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-channel-spicevmc.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-channel-spicevmc.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-smartcard-controller.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-smartcard-controller.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-smartcard-host-certificates.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-smartcard-host-certificates.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-smartcard-host.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-smartcard-host.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-smartcard-passthrough-spicevmc.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-smartcard-passthrough-spicevmc.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-smartcard-passthrough-tcp.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-smartcard-passthrough-tcp.xml
--
1.7.4
13 years, 8 months
[libvirt] [PATCH 0/2] Support booting from hostdev devices
by Jiri Denemark
These are a follow-up patches for per-device boot which extend current support
for booting from disks and NICs to assigned host devices.
Jiri Denemark (2):
Support booting from hostdev devices
qemu: Support booting from hostdev PCI devices
docs/formatdomain.html.in | 14 ++++++++++++--
docs/schemas/domain.rng | 3 +++
src/conf/domain_conf.c | 18 +++++++++++++++---
src/conf/domain_conf.h | 1 +
src/qemu/qemu_capabilities.c | 5 ++++-
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_command.c | 17 +++++++++++++++++
7 files changed, 53 insertions(+), 6 deletions(-)
--
1.7.4
13 years, 8 months
[libvirt] [PATCH v2] qemu: Add shortcut for HMP pass through
by Jiri Denemark
Currently users who want to use virDomainQemuMonitorCommand() API or
it's virsh equivalent has to use the same protocol as libvirt uses for
communication to qemu. Since the protocol is QMP with current qemu and
HMP much more usable for humans, one ends up typing something like the
following:
virsh qemu-monitor-command DOM \
'{"execute":"human-monitor-command","arguments":{"command-line":"info kvm"}}'
which is not a very convenient way of debugging qemu.
This patch introduces --hmp option to qemu-monitor-command, which says
that the provided command is in HMP. If libvirt uses QMP to talk with
qemu, the command will automatically be converted into QMP. So the
example above is simplified to just
virsh qemu-monitor-command --hmp DOM "info kvm"
Also the result is converted from
{"return":"kvm support: enabled\r\n"}
to just plain HMP:
kvm support: enabled
If libvirt talks to qemu in HMP, --hmp flag is obviously a noop.
---
Notes:
Version 2:
- document --hmp in virsh man page
- add missing virReportOOMError() in qemuMonitorArbitraryCommand()
include/libvirt/libvirt-qemu.h | 5 +++++
src/internal.h | 1 +
src/qemu/qemu_driver.c | 7 +++++--
src/qemu/qemu_monitor.c | 9 ++++++---
src/qemu/qemu_monitor.h | 5 ++++-
src/qemu/qemu_monitor_json.c | 30 ++++++++++++++++++++++++++----
src/qemu/qemu_monitor_json.h | 3 ++-
tools/virsh.c | 7 ++++++-
tools/virsh.pod | 7 +++++--
9 files changed, 60 insertions(+), 14 deletions(-)
diff --git a/include/libvirt/libvirt-qemu.h b/include/libvirt/libvirt-qemu.h
index 9c191c7..9257c2f 100644
--- a/include/libvirt/libvirt-qemu.h
+++ b/include/libvirt/libvirt-qemu.h
@@ -20,6 +20,11 @@
extern "C" {
# endif
+enum {
+ VIR_DOMAIN_QEMU_MONITOR_COMMAND_DEFAULT = 0,
+ VIR_DOMAIN_QEMU_MONITOR_COMMAND_HMP = (1 << 0), /* cmd is in HMP */
+} virDomainQemuMonitorCommandFlags;
+
int virDomainQemuMonitorCommand(virDomainPtr domain, const char *cmd,
char **result, unsigned int flags);
diff --git a/src/internal.h b/src/internal.h
index 11ba45f..e263684 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -38,6 +38,7 @@
# define N_(str) str
# include "libvirt/libvirt.h"
+# include "libvirt/libvirt-qemu.h"
# include "libvirt/virterror.h"
# include "libvirt_internal.h"
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index a3a68b1..cce115a 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -10237,8 +10237,9 @@ static int qemuDomainMonitorCommand(virDomainPtr domain, const char *cmd,
virDomainObjPtr vm = NULL;
int ret = -1;
qemuDomainObjPrivatePtr priv;
+ bool hmp;
- virCheckFlags(0, -1);
+ virCheckFlags(VIR_DOMAIN_QEMU_MONITOR_COMMAND_HMP, -1);
qemuDriverLock(driver);
vm = virDomainFindByUUID(&driver->domains, domain->uuid);
@@ -10264,10 +10265,12 @@ static int qemuDomainMonitorCommand(virDomainPtr domain, const char *cmd,
priv->monitor_warned = 1;
}
+ hmp = !!(flags & VIR_DOMAIN_QEMU_MONITOR_COMMAND_HMP);
+
if (qemuDomainObjBeginJobWithDriver(driver, vm) < 0)
goto cleanup;
qemuDomainObjEnterMonitorWithDriver(driver, vm);
- ret = qemuMonitorArbitraryCommand(priv->mon, cmd, result);
+ ret = qemuMonitorArbitraryCommand(priv->mon, cmd, result, hmp);
qemuDomainObjExitMonitorWithDriver(driver, vm);
if (qemuDomainObjEndJob(vm) == 0) {
vm = NULL;
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 0c14277..fdb6b79 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -2007,14 +2007,17 @@ int qemuMonitorDeleteSnapshot(qemuMonitorPtr mon, const char *name)
return ret;
}
-int qemuMonitorArbitraryCommand(qemuMonitorPtr mon, const char *cmd, char **reply)
+int qemuMonitorArbitraryCommand(qemuMonitorPtr mon,
+ const char *cmd,
+ char **reply,
+ bool hmp)
{
int ret;
- DEBUG("mon=%p, cmd=%s, reply=%p", mon, cmd, reply);
+ DEBUG("mon=%p, cmd=%s, reply=%p, hmp=%d", mon, cmd, reply, hmp);
if (mon->json)
- ret = qemuMonitorJSONArbitraryCommand(mon, cmd, reply);
+ ret = qemuMonitorJSONArbitraryCommand(mon, cmd, reply, hmp);
else
ret = qemuMonitorTextArbitraryCommand(mon, cmd, reply);
return ret;
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 92c550b..0ea1330 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -397,7 +397,10 @@ int qemuMonitorCreateSnapshot(qemuMonitorPtr mon, const char *name);
int qemuMonitorLoadSnapshot(qemuMonitorPtr mon, const char *name);
int qemuMonitorDeleteSnapshot(qemuMonitorPtr mon, const char *name);
-int qemuMonitorArbitraryCommand(qemuMonitorPtr mon, const char *cmd, char **reply);
+int qemuMonitorArbitraryCommand(qemuMonitorPtr mon,
+ const char *cmd,
+ char **reply,
+ bool hmp);
/**
* When running two dd process and using <> redirection, we need a
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index ca06e7e..d5e8d37 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -2457,22 +2457,44 @@ int qemuMonitorJSONDeleteSnapshot(qemuMonitorPtr mon, const char *name)
int qemuMonitorJSONArbitraryCommand(qemuMonitorPtr mon,
const char *cmd_str,
- char **reply_str)
+ char **reply_str,
+ bool hmp)
{
virJSONValuePtr cmd = NULL;
virJSONValuePtr reply = NULL;
int ret = -1;
- cmd = virJSONValueFromString(cmd_str);
+ if (!hmp) {
+ cmd = virJSONValueFromString(cmd_str);
+ } else {
+ cmd = qemuMonitorJSONMakeCommand("human-monitor-command",
+ "s:command-line", cmd_str,
+ NULL);
+ }
+
if (!cmd)
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
goto cleanup;
- *reply_str = virJSONValueToString(reply);
- if (!(*reply_str))
+ if (!hmp) {
+ if (!(*reply_str = virJSONValueToString(reply)))
+ goto cleanup;
+ } else if (qemuMonitorJSONCheckError(cmd, reply)) {
goto cleanup;
+ } else {
+ const char *data;
+ if (!(data = virJSONValueObjectGetString(reply, "return"))) {
+ qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("human monitor command was missing return data"));
+ goto cleanup;
+ }
+ if (!(*reply_str = strdup(data))) {
+ virReportOOMError();
+ goto cleanup;
+ }
+ }
ret = 0;
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index 4c47f10..4ae472a 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -209,6 +209,7 @@ int qemuMonitorJSONDeleteSnapshot(qemuMonitorPtr mon, const char *name);
int qemuMonitorJSONArbitraryCommand(qemuMonitorPtr mon,
const char *cmd_str,
- char **reply_str);
+ char **reply_str,
+ bool hmp);
#endif /* QEMU_MONITOR_JSON_H */
diff --git a/tools/virsh.c b/tools/virsh.c
index 59d099e..1f820e8 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -10176,6 +10176,7 @@ static const vshCmdInfo info_qemu_monitor_command[] = {
static const vshCmdOptDef opts_qemu_monitor_command[] = {
{"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
{"cmd", VSH_OT_DATA, VSH_OFLAG_REQ, N_("command")},
+ {"hmp", VSH_OT_BOOL, 0, N_("command is in human monitor protocol")},
{NULL, 0, 0, NULL}
};
@@ -10186,6 +10187,7 @@ cmdQemuMonitorCommand(vshControl *ctl, const vshCmd *cmd)
int ret = FALSE;
char *monitor_cmd;
char *result = NULL;
+ unsigned int flags = 0;
if (!vshConnectionUsability(ctl, ctl->conn))
goto cleanup;
@@ -10200,7 +10202,10 @@ cmdQemuMonitorCommand(vshControl *ctl, const vshCmd *cmd)
goto cleanup;
}
- if (virDomainQemuMonitorCommand(dom, monitor_cmd, &result, 0) < 0)
+ if (vshCommandOptBool(cmd, "hmp"))
+ flags |= VIR_DOMAIN_QEMU_MONITOR_COMMAND_HMP;
+
+ if (virDomainQemuMonitorCommand(dom, monitor_cmd, &result, flags) < 0)
goto cleanup;
printf("%s\n", result);
diff --git a/tools/virsh.pod b/tools/virsh.pod
index d6a16f2..bfaa67e 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -1253,10 +1253,13 @@ problems to the libvirt developers; the reports will be ignored.
=over 4
-=item B<qemu-monitor-command> I<domain> I<command>
+=item B<qemu-monitor-command> I<domain> I<command> optional I<--hmp>
Send an arbitrary monitor command I<command> to domain I<domain> through the
-qemu monitor. The results of the command will be printed on stdout.
+qemu monitor. The results of the command will be printed on stdout. If
+I<--hmp> is passed, the command is considered to be a human monitor command
+and libvirt will automatically convert it into QMP if needed. In that case
+the result will also be converted back from QMP.
=back
--
1.7.4
13 years, 8 months
[libvirt] [PATCH] macvtap.c: add parenthesis for similar expressions
by Davidlohr Bueso
It wouldn't hurt to add some parenthesis in the following two similar expression for better readability.
---
src/util/macvtap.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/util/macvtap.c b/src/util/macvtap.c
index 09d7b78..92147ab 100644
--- a/src/util/macvtap.c
+++ b/src/util/macvtap.c
@@ -1048,8 +1048,8 @@ doPortProfileOpSetLink(bool nltarget_kernel,
memcpy(ifla_vf_mac.mac, macaddr, 6);
- if (!nla_put(nl_msg, IFLA_VF_MAC, sizeof(ifla_vf_mac),
- &ifla_vf_mac) < 0)
+ if ((!nla_put(nl_msg, IFLA_VF_MAC, sizeof(ifla_vf_mac),
+ &ifla_vf_mac)) < 0)
goto buffer_too_small;
}
@@ -1060,8 +1060,8 @@ doPortProfileOpSetLink(bool nltarget_kernel,
.qos = 0,
};
- if (!nla_put(nl_msg, IFLA_VF_VLAN, sizeof(ifla_vf_vlan),
- &ifla_vf_vlan) < 0)
+ if ((!nla_put(nl_msg, IFLA_VF_VLAN, sizeof(ifla_vf_vlan),
+ &ifla_vf_vlan)) < 0)
goto buffer_too_small;
}
--
1.7.1
13 years, 8 months
[libvirt] [PATCHv4 0/5] smartcard, round 4
by Eric Blake
This should address all of the comment from round 3:
https://www.redhat.com/archives/libvir-list/2011-January/msg01034.html
In particular, there is no longer a device tied to host mode (qemu
uses NSS, which connects to the nss daemon rather than to a physical
device); the certificate entries for host-certificates mode are no
longer treated as paths, but as opaque names used within the database;
the database defaults to /etc/pki/nssdb/ if not otherwise specified
(hmm, I guess I haven't added support for $HOME/.pki/nssdb for
non-root users yet, but wanted to get this out for review now due
to a request from Alon). More notes on each patch.
Eric Blake (5):
smartcard: add XML support for <smartcard> device
smartcard: add domain conf support
smartcard: check for qemu capability
smartcard: enable SELinux support
smartcard: turn on qemu support
cfg.mk | 1 +
docs/formatdomain.html.in | 95 +++++-
docs/schemas/domain.rng | 66 ++++
src/conf/domain_conf.c | 366 +++++++++++++++++++-
src/conf/domain_conf.h | 52 +++-
src/libvirt_private.syms | 4 +
src/qemu/qemu_capabilities.c | 2 +
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_command.c | 95 +++++-
src/security/security_selinux.c | 76 ++++
.../qemuxml2argv-smartcard-controller.args | 7 +
.../qemuxml2argv-smartcard-controller.xml | 19 +
.../qemuxml2argv-smartcard-host-certificates.args | 8 +
.../qemuxml2argv-smartcard-host-certificates.xml | 20 +
.../qemuxml2argv-smartcard-host.args | 7 +
.../qemuxml2argv-smartcard-host.xml | 16 +
.../qemuxml2argv-smartcard-passthrough-tcp.args | 7 +
.../qemuxml2argv-smartcard-passthrough-tcp.xml | 19 +
tests/qemuxml2argvtest.c | 13 +
19 files changed, 859 insertions(+), 15 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-smartcard-controller.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-smartcard-controller.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-smartcard-host-certificates.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-smartcard-host-certificates.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-smartcard-host.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-smartcard-host.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-smartcard-passthrough-tcp.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-smartcard-passthrough-tcp.xml
--
1.7.3.5
13 years, 8 months