On Fri, Aug 22, 2014 at 12:47:03PM +0200, Maxime Leroy wrote:
This patch implements support for the ivshmem device
in QEMU.
Example from this xml:
<shmem name='ivshmem0' model='ivshmem'>
<server path='/tmp/socket-ivshmem0'/>
<size unit='M'>32</size>
<msi vectors='32' ioeventfd='on'/>
</shmem>
The following QEMU line is built:
-device ivshmem,size=32m,vectors=32,chardev=charshmem0,msi=on,
ioeventfd=on,role=master
-chardev socket,path=/tmp/socket-ivshmem0,id=charshmem0
Note: PCI hotpluging is not implemented.
Signed-off-by: Maxime Leroy <maxime.leroy(a)6wind.com>
---
src/qemu/qemu_command.c | 105 +++++++++++++++++++++++++++++++++++++++++++++++-
src/qemu/qemu_command.h | 4 ++
src/qemu/qemu_hotplug.c | 1 +
3 files changed, 109 insertions(+), 1 deletion(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 0d7b12d..9fcceae 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1019,6 +1019,10 @@ qemuAssignDeviceAliases(virDomainDefPtr def, virQEMUCapsPtr
qemuCaps)
if (virAsprintf(&def->hubs[i]->info.alias, "hub%zu", i) <
0)
return -1;
}
+ for (i = 0; i < def->nshmems; i++) {
+ if (virAsprintf(&def->shmems[i]->info.alias, "shmem%zu", i)
< 0)
+ return -1;
+ }
for (i = 0; i < def->nsmartcards; i++) {
if (virAsprintf(&def->smartcards[i]->info.alias,
"smartcard%zu", i) < 0)
return -1;
@@ -5043,6 +5047,100 @@ qemuBuildRedirdevDevStr(virDomainDefPtr def,
return NULL;
}
+static char *
+qemuBuildIvshmemDevStr(virDomainDefPtr def,
+ virDomainShmemDefPtr dev,
+ virQEMUCapsPtr qemuCaps)
+{
+ virBuffer buf = VIR_BUFFER_INITIALIZER;
+ virDomainIvshmemDefPtr ivshmem = &dev->data.ivshmem;
+
+ if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_IVSHMEM)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("ivshmem device is not supported by QEMU"));
+ goto error;
+ }
+
+ virBufferAddLit(&buf, "ivshmem");
+ if (ivshmem->size)
+ virBufferAsprintf(&buf, ",size=%llum", ivshmem->size / (1024 *
1024));
+
It will sometimes format the command-line parameter to size=0m, which
will terribly fail. We should add it to the command-line with the
smallest scale possible, so it can be configured to the tiniest bit
(and it will also get rid of this error).
Other than that, the patch looks fine.
Martin