[libvirt] Supporting vhost-net and macvtap in libvirt for QEMU
by Anthony Liguori
Disclaimer: I am neither an SR-IOV nor a vhost-net expert, but I've CC'd
people that are who can throw tomatoes at me for getting bits wrong :-)
I wanted to start a discussion about supporting vhost-net in libvirt.
vhost-net has not yet been merged into qemu but I expect it will be soon
so it's a good time to start this discussion.
There are two modes worth supporting for vhost-net in libvirt. The
first mode is where vhost-net backs to a tun/tap device. This is
behaves in very much the same way that -net tap behaves in qemu today.
Basically, the difference is that the virtio backend is in the kernel
instead of in qemu so there should be some performance improvement.
Current, libvirt invokes qemu with -net tap,fd=X where X is an already
open fd to a tun/tap device. I suspect that after we merge vhost-net,
libvirt could support vhost-net in this mode by just doing -net
vhost,fd=X. I think the only real question for libvirt is whether to
provide a user visible switch to use vhost or to just always use vhost
when it's available and it makes sense. Personally, I think the later
makes sense.
The more interesting invocation of vhost-net though is one where the
vhost-net device backs directly to a physical network card. In this
mode, vhost should get considerably better performance than the current
implementation. I don't know the syntax yet, but I think it's
reasonable to assume that it will look something like -net
tap,dev=eth0. The effect will be that eth0 is dedicated to the guest.
On most modern systems, there is a small number of network devices so
this model is not all that useful except when dealing with SR-IOV
adapters. In that case, each physical device can be exposed as many
virtual devices (VFs). There are a few restrictions here though. The
biggest is that currently, you can only change the number of VFs by
reloading a kernel module so it's really a parameter that must be set at
startup time.
I think there are a few ways libvirt could support vhost-net in this
second mode. The simplest would be to introduce a new tag similar to
<source network='br0'>. In fact, if you probed the device type for the
network parameter, you could probably do something like <source
network='eth0'> and have it Just Work.
Another model would be to have libvirt see an SR-IOV adapter as a
network pool whereas it handled all of the VF management. Considering
how inflexible SR-IOV is today, I'm not sure whether this is the best model.
Has anyone put any more thought into this problem or how this should be
modeled in libvirt? Michael, could you share your current thinking for
-net syntax?
--
Regards,
Anthony Liguori
1 year, 2 months
[libvirt] New application
by Maciej Nabożny
Hello,
I'm developer of CC1 project in Institute of Nuclear Physics in
Cracow. We are creating cloud computing system based on Libvirt. Is it
possible to add link to our project at yours website in applications
section?
Title: CC1 Project (http://cc1.ifj.edu.pl)
Description: The Cloud Computing for Science and Economy project
At this time we are using version 0.8.3, but as soon as debian 7 will
we stable, we are going to migrate to newer version of Libvirt.
Regards,
Maciej Nabożny
11 years, 7 months
[libvirt] [PATCH 0/4] Multiple problems with saving to block devices
by Daniel P. Berrange
This patch series makes it possible to save to a block device,
instead of a plain file. There were multiple problems
- WHen save failed, we might de-reference a NULL pointer
- When save failed, we unlinked the device node !!
- The approach of using >> to append, doesn't work with block devices
- CGroups was blocking QEMU access to the block device when enabled
One remaining problem is not in libvirt, but rather QEMU. The QEMU
exec: based migration often fails to detect failure of the command
and will thus hang forever attempting a migration that'll never
succeed! Fortunately you can now work around this in libvirt using
the virsh domjobabort command
11 years, 9 months
Re: [libvirt] Memory free in libvirt JNA
by Benjamin Wang (gendwang)
Hi,
I wrote a code to verify the memory leak problem as following.
C code in so:
void checkJNAMemLeak1(int **head, int *length)
{
long i = 0;
*head = (int *)malloc(sizeof(int) * 100000000);
for(i=0; i<100000000; i++)
{
(*head)[i] = 1;
}
*length = 100000000;
}
Java code:
public static void testJNAMemLeak1()
{
PointerByReference head = new PointerByReference();
IntByReference length = new IntByReference();
while(true)
{
libben.checkJNAMemLeak1(head, length);
System.out.println(length.getValue());
sleep(1);
}
}
When we check memory by top command, the virt and res will increase very quickly. When we check with jconsole, there is no memory in Java heap. Even I execute GC manually by jconsole. Nothing happen.
If I change java code as following:
public static void testJNAMemLeak1()
{
PointerByReference head = new PointerByReference();
IntByReference length = new IntByReference();
while(true)
{
libben.checkJNAMemLeak1(head, length);
System.out.println(length.getValue());
sleep(1);
libc.free(head.getValue());
}
}
public static void testJNAMemLeak1()
{
PointerByReference head = new PointerByReference();
IntByReference length = new IntByReference();
while(true)
{
libben.checkJNAMemLeak1(head, length);
System.out.println(length.getValue());
sleep(1);
libc.free(head.getValue());
}
}
Then everything works well. The virt and res will not increase.
I think we must provide the free functions for all the memory allocated by libvirt.
B.R.
Benjamin Wang
-----Original Message-----
From: Benjamin Wang (gendwang)
Sent: 2012年9月7日 15:22
To: libvir-list(a)redhat.com
Cc: 'veillard(a)redhat.com'; Yang Zhou (yangzho)
Subject: RE: Memory free in libvirt JNA
Hi,
Overview Part of JNA API describes as following:
1. Description1:
If the native method returns char* and actually allocates memory, a return type of Pointer should be used to avoid leaking the memory. It is then up to you to take the necessary steps to free the allocated memory.
2. Description2:
Declare the method as returning a Structure of the appropriate type, then invoke Structure.toArray(int) to convert to an array of initialized structures of the appropriate size. Note that your Structure class must have a no-args constructor, and you are responsible for freeing the returned memory if applicable in whatever way is appropriate for the called function.
And the example code shows as following:
// Original C code
struct Display* get_displays(int* pcount); void free_displays(struct Display* displays);
// Equivalent JNA mapping
Display get_displays(IntByReference pcount); void free_displays(Display[] displays); ...
IntByReference pcount = new IntByReference(); Display d = lib.get_displays(pcount); Display[] displays = (Display[])d.toArray(pcount.getValue());
...
lib.free_displays(displays);
That's to say. All the memory allocated by native code must be freed explicitly in JNA part. We must add some free memory methods to support the memory-freeing.
Any comments?
B.R.
Benjamin Wang
-----Original Message-----
From: Daniel Veillard [mailto:veillard@redhat.com]
Sent: 2012年8月20日 14:25
To: Benjamin Wang (gendwang)
Cc: stoty(a)tvnet.hu; Daniel.Schwager(a)dtnet.de
Subject: Re: Memory free in libvirt JNA
On Mon, Aug 20, 2012 at 05:15:45AM +0000, Benjamin Wang (gendwang) wrote:
> Hi Veillard,
> Thanks for your reply. I checked the current Libvirt-JNA
> implementation. I find that a method named "free" defined in Domain
> class which is used to free the domain object. If this is mandatory, that's to say, we should a lot of methods into the current Libvirt-jna implementation to free the memory which is allocated by libvirt API. Please correct me!
As far as I understat free() is aliased as finalize() on that object so the java runtime will call free() automatically on garbage collection. I'm not a java expert, check some Java litterature for more details about how this is done and the cases where
free() might be better called directly.
Daniel
--
Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
daniel(a)veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/
11 years, 11 months
[libvirt] [PATCHv4 00/51] another round of snapshot patches
by Eric Blake
I think I've addressed most findings from round 3 - by implementing
the ability to redefine a snapshot, it becomes possible to restore
snapshot hierarchy when recreating a transient domain by the same
name. New goodies in this round: several bug fixes, add virsh
snapshot-edit, drop undefine --snapshots-full (you can only remove
snapshot metadata on undefine). I tested as I went, but this went
through so many rebases that there may be some nasties that snuck
in; but I wanted to get this posted now. I also know that I'm
missing at least one major feature requested in the v3 review:
namely, transient domains _should_ auto-remove snapshot metadata
files when they halt, but right now aren't doing that.
v3 was at:
https://www.redhat.com/archives/libvir-list/2011-August/msg01132.html
Also available here:
git fetch git://repo.or.cz/libvirt/ericb.git snapshot
or browse online at:
http://repo.or.cz/w/libvirt/ericb.git/shortlog/refs/heads/snapshot
I'm also trying to group things by several bugzilla related to
various patches (looks like I still need to create a few):
Eric Blake (51):
https://bugzilla.redhat.com/show_bug.cgi?id=674537
snapshot: fix corner case on OOM during creation
https://bugzilla.redhat.com/show_bug.cgi?id=733762
snapshot: better events when starting paused
snapshot: fine-tune ability to start paused
snapshot: expose --running and --paused in virsh
snapshot: fine-tune qemu saved images starting paused
snapshot: improve reverting to qemu paused snapshots
snapshot: properly revert qemu to offline snapshots
snapshot: fine-tune qemu snapshot revert states
no bug filed yet... should be one about no stale metadata
snapshot: allow deletion of just snapshot metadata
snapshot: add snapshot-list --parent to virsh
https://bugzilla.redhat.com/show_bug.cgi?id=733529
snapshot: speed up snapshot location
snapshot: avoid crash when deleting qemu snapshots
snapshot: track current domain across deletion of children
snapshot: simplify acting on just children
no bug filed yet... should be one about no stale metadata
snapshot: let qemu discard only snapshot metadata
snapshot: identify which snapshots have metadata
snapshot: reflect new dumpxml and list options in virsh
snapshot: identify qemu snapshot roots
snapshot: allow recreation of metadata
snapshot: refactor virsh snapshot creation
snapshot: improve virsh snapshot-create, add snapshot-edit
snapshot: add qemu snapshot creation without metadata
no bug filed yet... should be one about snapshot migration
snapshot: add qemu snapshot redefine support
snapshot: prevent stranding snapshot data on domain destruction
snapshot: teach virsh about new undefine flags
snapshot: refactor some qemu code
snapshot: cache qemu-img location
snapshot: support new undefine flags in qemu
snapshot: prevent migration from stranding snapshot data
https://bugzilla.redhat.com/show_bug.cgi?id=638510
snapshot: refactor domain xml output
snapshot: allow full domain xml in snapshot
snapshot: correctly escape generated xml
snapshot: update rng to support full domain in xml
snapshot: store qemu domain details in xml
snapshot: additions to domain xml for disks
snapshot: reject transient disks where code is not ready
snapshot: introduce new deletion flag
snapshot: expose new delete flag in virsh
snapshot: allow halting after snapshot
snapshot: expose halt-after-creation in virsh
snapshot: wire up new qemu monitor command
snapshot: support extra state in snapshots
snapshot: add <disks> to snapshot xml
snapshot: also support disks by path
snapshot: add virsh domblklist command
snapshot: add flag for requesting disk snapshot
snapshot: wire up disk-only flag to snapshot-create
snapshot: reject unimplemented disk snapshot features
snapshot: make it possible to audit external snapshot
snapshot: wire up live qemu disk snapshots
snapshot: use SELinux and lock manager with external snapshots
docs/formatdomain.html.in | 40 +-
docs/formatsnapshot.html.in | 269 ++-
docs/schemas/Makefile.am | 1 +
docs/schemas/domain.rng | 2555 +-------------------
docs/schemas/{domain.rng => domaincommon.rng} | 32 +-
docs/schemas/domainsnapshot.rng | 84 +-
examples/domain-events/events-c/event-test.c | 37 +-
include/libvirt/libvirt.h.in | 66 +-
src/conf/domain_audit.c | 12 +-
src/conf/domain_audit.h | 4 +-
src/conf/domain_conf.c | 902 ++++++--
src/conf/domain_conf.h | 76 +-
src/esx/esx_driver.c | 38 +-
src/libvirt.c | 256 ++-
src/libvirt_private.syms | 8 +
src/libxl/libxl_conf.c | 5 +
src/libxl/libxl_driver.c | 11 +-
src/qemu/qemu_command.c | 5 +
src/qemu/qemu_conf.h | 1 +
src/qemu/qemu_driver.c | 1532 +++++++++---
src/qemu/qemu_hotplug.c | 18 +-
src/qemu/qemu_migration.c | 48 +-
src/qemu/qemu_migration.h | 2 -
src/qemu/qemu_monitor.c | 24 +
src/qemu/qemu_monitor.h | 4 +
src/qemu/qemu_monitor_json.c | 33 +
src/qemu/qemu_monitor_json.h | 4 +
src/qemu/qemu_monitor_text.c | 40 +
src/qemu/qemu_monitor_text.h | 4 +
src/qemu/qemu_process.c | 11 +-
src/uml/uml_driver.c | 56 +-
src/vbox/vbox_tmpl.c | 43 +-
src/xen/xend_internal.c | 12 +-
src/xenxs/xen_sxpr.c | 5 +
src/xenxs/xen_xm.c | 5 +
tests/domainsnapshotxml2xmlin/disk_snapshot.xml | 16 +
tests/domainsnapshotxml2xmlout/disk_snapshot.xml | 77 +
tests/domainsnapshotxml2xmlout/full_domain.xml | 35 +
.../qemuxml2argv-disk-snapshot.args | 7 +
.../qemuxml2argv-disk-snapshot.xml | 39 +
.../qemuxml2argv-disk-transient.xml | 27 +
tests/qemuxml2argvtest.c | 2 +
tests/virsh-optparse | 20 +
tools/virsh.c | 772 +++++-
tools/virsh.pod | 214 ++-
45 files changed, 3978 insertions(+), 3474 deletions(-)
copy docs/schemas/{domain.rng => domaincommon.rng} (98%)
create mode 100644 tests/domainsnapshotxml2xmlin/disk_snapshot.xml
create mode 100644 tests/domainsnapshotxml2xmlout/disk_snapshot.xml
create mode 100644 tests/domainsnapshotxml2xmlout/full_domain.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-snapshot.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-snapshot.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-transient.xml
--
1.7.4.4
12 years, 1 month
[libvirt] [PATCH] Added QEMU support for IVSHMEM devices
by Shawn Furrow
*Created at Virginia Tech's Systems Software Research Group
This patch adds the XML schema and implementation for IVSHMEM device driver
support. Currently it defaults to using interrupts. A sample IVSHMEM entry
in the VM's XML file is:
<ivshmem id='nahanni' size='16834' path='/tmp/'/>
---
docs/schemas/domaincommon.rng | 17 +++++
src/conf/domain_conf.c | 152 ++++++++++++++++++++++++++++++++++++++++-
src/conf/domain_conf.h | 16 ++++-
src/qemu/qemu_command.c | 75 ++++++++++++++++++++
src/qemu/qemu_command.h | 6 ++
5 files changed, 264 insertions(+), 2 deletions(-)
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index f47fdad..ddf8eb1 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -2576,6 +2576,23 @@
</optional>
</element>
</define>
+ <define name="ivshmem">
+ <element name="ivshmem">
+ <attribute name="id">
+ <ref name="deviceName">
+ </attribute>
+ <optional>
+ <attribute name="size">
+ <ref name="memoryKB">
+ </attribute>
+ </optional>
+ <optional>
+ <attribute name="path">
+ <ref name="filePath">
+ </attribute>
+ </optional>
+ </element>
+ </define>
<define name="parallel">
<element name="parallel">
<ref name="qemucdev"/>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 4aa08d0..0cd2f98 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -156,7 +156,8 @@ VIR_ENUM_IMPL(virDomainDevice, VIR_DOMAIN_DEVICE_LAST,
"redirdev",
"smartcard",
"chr",
- "memballoon")
+ "memballoon",
+ "ivshmem")
VIR_ENUM_IMPL(virDomainDeviceAddress, VIR_DOMAIN_DEVICE_ADDRESS_TYPE_LAST,
"none",
@@ -1374,6 +1375,16 @@ void virDomainMemballoonDefFree(virDomainMemballoonDefPtr def)
VIR_FREE(def);
}
+void virDomainIvshmemDefFree(virDomainIvshmemDefPtr def)
+{
+ if (!def)
+ return;
+
+ virDomainDeviceInfoClear(&def->info);
+
+ VIR_FREE(def);
+}
+
void virDomainWatchdogDefFree(virDomainWatchdogDefPtr def)
{
if (!def)
@@ -1707,6 +1718,8 @@ void virDomainDefFree(virDomainDefPtr def)
virDomainMemballoonDefFree(def->memballoon);
+ virDomainIvshmemDefFree(dev->ivshmem);
+
for (i = 0; i < def->nseclabels; i++)
virSecurityLabelDefFree(def->seclabels[i]);
VIR_FREE(def->seclabels);
@@ -2136,6 +2149,12 @@ int virDomainDeviceInfoIterate(virDomainDefPtr def,
if (cb(def, &device, &def->memballoon->info, opaque) < 0)
return -1;
}
+ if (def->ivshmem) {
+ device.type = VIR_DOMAIN_DEVICE_IVSHMEM;
+ device.data.ivshmem = def->ivshmem;
+ if (cb(def, &device, &def->ivshmem->info, opaque) < 0)
+ return -1;
+ }
device.type = VIR_DOMAIN_DEVICE_HUB;
for (i = 0; i < def->nhubs ; i++) {
device.data.hub = def->hubs[i];
@@ -6935,6 +6954,69 @@ error:
goto cleanup;
}
+static virDomainIvshmemDefPtr
+virDomainIvshmemDefParseXML(const xmlNodePtr node,
+ unsigned int flags)
+{
+ char *id = NULL;
+ char *size = NULL;
+ char *path = NULL;
+ virDomainIvshmemDefPtr def;
+
+ if (VIR_ALLOC(def) < 0) {
+ virReportOOMError();
+ return NULL;
+ }
+
+ id = virXMLPropString(node, "id");
+ VIR_DEBUG("ivshmem: id = '%s'", id);
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("ivshmem id=' %s'"), id);
+ if (id == NULL) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("ERROR: ivshmem, id not defined' %s'"), id);
+ goto error;
+ }
+
+ def->id = id;
+ size = virXMLPropString(node, "size");
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("ivshmem size=' %s'"), size);
+
+ VIR_DEBUG("ivshmem: size = '%s'", size);
+ if (size) {
+ if (virStrToLong_i(size, NULL, 10, &def->size) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("cannot parse ivshmem size %s"), size);
+ VIR_FREE(size);
+ goto error;
+ }
+ } else {
+ def->size = 16834;
+ }
+
+ path = virXMLPropString(node, "path");
+ VIR_DEBUG("ivshmem: path = '%s'", path);
+ if (path == NULL) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("ERROR: ivshmem, path not defined' %s'"), path);
+ goto error;
+ }
+ def->path = path;
+
+ if (virDomainDeviceInfoParseXML(node, NULL, &def->info, flags) < 0)
+ goto error;
+
+cleanup:
+ VIR_FREE(size);
+ return def;
+
+error:
+ virDomainIvshmemDefFree(def);
+ def = NULL;
+ goto cleanup;
+}
+
static virSysinfoDefPtr
virSysinfoParseXML(const xmlNodePtr node,
xmlXPathContextPtr ctxt)
@@ -9742,6 +9824,28 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
}
}
+ /* analysis of the ivshmem devices */
+ def->ivshmem = NULL;
+ if ((n = virXPathNodeSet("./devices/ivshmem", ctxt, &nodes)) < 0) {
+ goto error;
+ }
+
+ if (n > 0) {
+ virDomainIvshmemDefPtr ivshmem =
+ virDomainIvshmemDefParseXML(nodes[0], flags);
+ if (!ivshmem)
+ goto error;
+
+ def->ivshmem = ivshmem;
+ VIR_FREE(nodes);
+ } else if (def->virtType != VIR_DOMAIN_VIRT_QEMU) {
+ /* TODO: currently ivshmem only on QEMU */
+ virDomainIvshmemDefPtr ivshmem;
+ if (VIR_ALLOC(ivshmem) < 0)
+ goto no_memory;
+ def->ivshmem = 0;
+ }
+
/* analysis of the hub devices */
if ((n = virXPathNodeSet("./devices/hub", ctxt, &nodes)) < 0) {
goto error;
@@ -12673,6 +12777,49 @@ virDomainMemballoonDefFormat(virBufferPtr buf,
return 0;
}
+
+static int
+virDomainIvshmemDefFormat(virBufferPtr buf,
+ virDomainIvshmemDefPtr def,
+ unsigned int flags)
+{
+ const char *id = def->id;
+ const char *path = def->path;
+
+ if (!id) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("unexpected ivshmem id = %s"), def->id);
+ return -1;
+ }
+ if (!def->size) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("unexpected ivshmem size = %d"), def->size);
+ return -1;
+ }
+
+ if (!path) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("unexpected ivshmem id = %s"), def->path);
+ return -1;
+ }
+
+ virBufferAsprintf(buf, " <ivshmem id='%s'", id);
+ virBufferAsprintf(buf, " size='%d'", def->size);
+ virBufferAsprintf(buf, " path='%s'", path);
+
+ if (virDomainDeviceInfoIsSet(&def->info, flags)) {
+ virBufferAddLit(buf, ">\n");
+ if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
+ return -1;
+ virBufferAddLit(buf, " </ivshmem>\n");
+ } else {
+ virBufferAddLit(buf, "/>\n");
+ }
+
+ return 0;
+}
+
+
static int
virDomainSysinfoDefFormat(virBufferPtr buf,
virSysinfoDefPtr def)
@@ -13828,6 +13975,9 @@ virDomainDefFormatInternal(virDomainDefPtr def,
if (def->memballoon)
virDomainMemballoonDefFormat(buf, def->memballoon, flags);
+ if (def->ivshmem)
+ virDomainIvshmemDefFormat(buf, def->ivshmem, flags);
+
virBufferAddLit(buf, " </devices>\n");
virBufferAdjustIndent(buf, 2);
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 1a61318..78bdf84 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -114,6 +114,9 @@ typedef virDomainSnapshotObj *virDomainSnapshotObjPtr;
typedef struct _virDomainSnapshotObjList virDomainSnapshotObjList;
typedef virDomainSnapshotObjList *virDomainSnapshotObjListPtr;
+typedef struct _virDomainIvshmemDef virDomainIvshmemDef;
+typedef virDomainIvshmemDef *virDomainIvshmemDefPtr;
+
/* Flags for the 'type' field in virDomainDeviceDef */
typedef enum {
VIR_DOMAIN_DEVICE_NONE = 0,
@@ -133,6 +136,7 @@ typedef enum {
VIR_DOMAIN_DEVICE_SMARTCARD,
VIR_DOMAIN_DEVICE_CHR,
VIR_DOMAIN_DEVICE_MEMBALLOON,
+ VIR_DOMAIN_DEVICE_IVSHMEM,
VIR_DOMAIN_DEVICE_LAST
} virDomainDeviceType;
@@ -157,7 +161,8 @@ struct _virDomainDeviceDef {
virDomainRedirdevDefPtr redirdev;
virDomainSmartcardDefPtr smartcard;
virDomainChrDefPtr chr;
- virDomainMemballoonDefPtr memballoon;
+ virDomainMemballoonDefPtr memballoon,
+ virDomainIvshmemDefPtr ivshmem;
} data;
};
@@ -1344,6 +1349,12 @@ struct _virDomainMemballoonDef {
virDomainDeviceInfo info;
};
+struct _virDomainIvshmemDef {
+ char *id;
+ int size;
+ char *path;
+ virDomainDeviceInfo info;
+};
enum virDomainSmbiosMode {
VIR_DOMAIN_SMBIOS_NONE,
@@ -1752,6 +1763,7 @@ struct _virDomainDef {
/* Only 1 */
virDomainWatchdogDefPtr watchdog;
virDomainMemballoonDefPtr memballoon;
+ virDomainIvshmemDefPtr ivshmem;
virCPUDefPtr cpu;
virSysinfoDefPtr sysinfo;
virDomainRedirFilterDefPtr redirfilter;
@@ -1859,6 +1871,7 @@ int virDomainChrSourceDefCopy(virDomainChrSourceDefPtr src,
void virDomainSoundCodecDefFree(virDomainSoundCodecDefPtr def);
void virDomainSoundDefFree(virDomainSoundDefPtr def);
void virDomainMemballoonDefFree(virDomainMemballoonDefPtr def);
+void virDomainIvshmemDefFree(virDomainIvshmemDefPtr def);
void virDomainWatchdogDefFree(virDomainWatchdogDefPtr def);
void virDomainVideoDefFree(virDomainVideoDefPtr def);
virDomainHostdevDefPtr virDomainHostdevDefAlloc(void);
@@ -2194,6 +2207,7 @@ VIR_ENUM_DECL(virDomainSoundCodec)
VIR_ENUM_DECL(virDomainSoundModel)
VIR_ENUM_DECL(virDomainMemDump)
VIR_ENUM_DECL(virDomainMemballoonModel)
+VIR_ENUM_DECL(virDomainIvshmemModel)
VIR_ENUM_DECL(virDomainSmbiosMode)
VIR_ENUM_DECL(virDomainWatchdogModel)
VIR_ENUM_DECL(virDomainWatchdogAction)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index e7bb88e..6c66075 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -770,6 +770,10 @@ qemuAssignDeviceAliases(virDomainDefPtr def, qemuCapsPtr caps)
if (virAsprintf(&def->memballoon->info.alias, "balloon%d", 0) < 0)
goto no_memory;
}
+ if (def->ivshmem) {
+ if (virAsprintf(&def->ivshmem->info.alias, "ivshmem%d", 0) < 0)
+ goto no_memory;
+ }
return 0;
@@ -3245,6 +3249,58 @@ error:
return NULL;
}
+//adds the options for the "-device" portion of QEMU command line for ivshmem
+char *
+qemuBuildIvshmemDevStr(virDomainIvshmemDefPtr dev,
+ qemuCapsPtr caps)
+{
+virBuffer buf = VIR_BUFFER_INITIALIZER;
+
+ virBufferAddLit(&buf, "ivshmem");
+ virBufferAsprintf(&buf, ",chardev=%s", dev->id);
+ virBufferAsprintf(&buf, ",size=%dm", dev->size/1024);
+ virBufferAsprintf(&buf, ",ioeventfd=on");
+ virBufferAsprintf(&buf, ",vectors=8");
+ //virBufferAsprintf(&buf, ",shm=%s", dev->id);
+ if (qemuBuildDeviceAddressStr(&buf, &dev->info, caps) < 0)
+ goto error;
+
+ if (virBufferError(&buf)) {
+ virReportOOMError();
+ goto error;
+ }
+
+ return virBufferContentAndReset(&buf);
+
+error:
+ virBufferFreeAndReset(&buf);
+ return NULL;
+}
+
+//adds the options for the "-chardev" portion of QEMU command line for ivshmem
+char *
+qemuBuildIvshmemCharDevStr(virDomainIvshmemDefPtr dev,
+ qemuCapsPtr caps)
+{
+virBuffer buf = VIR_BUFFER_INITIALIZER;
+
+ virBufferAddLit(&buf, "socket");
+ virBufferAsprintf(&buf, ",id=%s", dev->id);
+ virBufferAsprintf(&buf, ",path=%s%s", dev->path,dev->id);
+ if (qemuBuildDeviceAddressStr(&buf, &dev->info, caps) < 0)
+ goto error;
+
+ if (virBufferError(&buf)) {
+ virReportOOMError();
+ goto error;
+ }
+
+ return virBufferContentAndReset(&buf);
+
+error:
+ virBufferFreeAndReset(&buf);
+ return NULL;
+}
char *
qemuBuildUSBInputDevStr(virDomainInputDefPtr dev,
@@ -6582,6 +6638,25 @@ qemuBuildCommandLine(virConnectPtr conn,
}
}
+ // adds ivshmem QEMU command line entries
+ if ((def->ivshmem) && (def->ivshmem->id != NULL)) {
+ char *optstr;
+ virCommandAddArg(cmd, "-chardev");
+ optstr = qemuBuildIvshmemCharDevStr(def->ivshmem, caps);
+ if (!optstr)
+ goto error;
+ virCommandAddArg(cmd, optstr);
+
+ optstr = NULL;
+
+ virCommandAddArg(cmd, "-device");
+ optstr = qemuBuildIvshmemDevStr(def->ivshmem, caps);
+ if (!optstr)
+ goto error;
+ virCommandAddArg(cmd, optstr);
+ VIR_FREE(optstr);
+ }
+
if (snapshot)
virCommandAddArgList(cmd, "-loadvm", snapshot->def->name, NULL);
diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
index 939833d..80e7565 100644
--- a/src/qemu/qemu_command.h
+++ b/src/qemu/qemu_command.h
@@ -118,6 +118,12 @@ char * qemuBuildWatchdogDevStr(virDomainWatchdogDefPtr dev,
char * qemuBuildMemballoonDevStr(virDomainMemballoonDefPtr dev,
qemuCapsPtr caps);
+char * qemuBuildIvshmemDevStr(virDomainIvshmemDefPtr dev,
+ qemuCapsPtr caps);
+
+char * qemuBuildIvshmemCharDevStr(virDomainIvshmemDefPtr dev,
+ qemuCapsPtr caps);
+
char * qemuBuildUSBInputDevStr(virDomainInputDefPtr dev,
qemuCapsPtr caps);
--
1.7.0.4
12 years, 2 months
[libvirt] Need help of guest lifecycle control
by Zhimou Peng
Hi,
I have a question about guest lifecycle control, many content of element not works, i don't know if i use it in a wrong way.
#virsh shutdown aaa
<on_poweroff>destroy</on_poweroff>
Domain aaa shut off and not power up again. -----> expect
<on_poweroff>restart</on_poweroff>
should power up again but not. -----> not expect
<on_poweroff>preserve</on_poweroff>
guest poweroff, nothing happend. ----> how to use it ?
<on_poweroff>rename-restart</on_poweroff>
guest poweroff, and should boot up again with newname? but it's only powered off. --->not expect
-------------------------------------------------------------------------------------
#virsh reboot aaa
<on_reboot>destroy</on_reboot>
guest not boot up again. it works.
<on_reboot>restart</on_reboot>
guest boot up again. it works.
<on_reboot>preserve</on_reboot>
guest poweroff, nothing happend. -----> how to use it ?
<on_reboot>rename-restart</on_reboot>
guest poweroff, and should boot up again with newname. but it's only powered off. --->not expect
--------------------------------------------------------------------------------------
<on_crash>xxxxxxx</on_crash> --->qemu not support this yet, right? https://bugzilla.redhat.com/show_bug.cgi?id=833530
zhpeng
BR
12 years, 2 months
[libvirt] [RFC] [PATCH v3 1/6] add a configure option --with-fuse to prepare introduction of fuse support for libvirt lxc
by Gao feng
add a configure option --with-fuse to prepare introduction
of fuse support for libvirt lxc.
With help from Daniel
Signed-off-by: Gao feng <gaofeng(a)cn.fujitsu.com>
---
configure.ac | 35 +++++++++++++++++++++++++++++++++++
libvirt.spec.in | 9 +++++++++
2 files changed, 44 insertions(+), 0 deletions(-)
diff --git a/configure.ac b/configure.ac
index 47a72b9..cc7de9d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1847,6 +1847,36 @@ AC_SUBST([CAPNG_CFLAGS])
AC_SUBST([CAPNG_LIBS])
+dnl libfuse
+AC_ARG_WITH([fuse],
+ AC_HELP_STRING([--with-fuse], [use libfuse to proivde fuse filesystem support for libvirt lxc]),
+ [],
+ [with_fuse=check])
+dnl
+dnl This check looks for 'fuse'
+dnl
+FUSE_CFLAGS=
+FUSE_LIBS=
+if test "x$with_fuse" != "xno"; then
+ PKG_CHECK_MODULES([FUSE], [fuse],
+ [with_fuse=yes], [
+ if test "x$with_fuse" = "xcheck" ; then
+ with_fuse=no
+ else
+ AC_MSG_ERROR(
+ [You must install fuse-devel to compile libvirt])
+ fi
+ ])
+ if test "x$with_fuse" = "xyes" ; then
+ FUSE_LIBS="-lfuse"
+ FUSE_CFLAGS="-D_FILE_OFFSET_BITS=64"
+ AC_DEFINE_UNQUOTED([HAVE_FUSE], 1, [whether fuse is available for libvirt lxc])
+ fi
+fi
+AM_CONDITIONAL([HAVE_FUSE], [test "x$with_fuse" = "xyes"])
+AC_SUBST([FUSE_CFLAGS])
+AC_SUBST([FUSE_LIBS])
+
dnl virsh libraries
AC_CHECK_HEADERS([readline/readline.h])
@@ -3103,6 +3133,11 @@ AC_MSG_NOTICE([ capng: $CAPNG_CFLAGS $CAPNG_LIBS])
else
AC_MSG_NOTICE([ capng: no])
fi
+if test "$with_fuse" = "yes" ; then
+AC_MSG_NOTICE([ fuse: $FUSE_CFLAGS $FUSE_LIBS])
+else
+AC_MSG_NOTICE([ fuse: no])
+fi
if test "$with_xen" = "yes" ; then
AC_MSG_NOTICE([ xen: $XEN_CFLAGS $XEN_LIBS])
else
diff --git a/libvirt.spec.in b/libvirt.spec.in
index 8c4c08d..a63999c 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -92,6 +92,7 @@
# A few optional bits off by default, we enable later
%define with_polkit 0%{!?_without_polkit:0}
%define with_capng 0%{!?_without_capng:0}
+%define with_fuse 0%{!?_without_fuse:0}
%define with_netcf 0%{!?_without_netcf:0}
%define with_udev 0%{!?_without_udev:0}
%define with_hal 0%{!?_without_hal:0}
@@ -490,6 +491,9 @@ BuildRequires: numactl-devel
%if %{with_capng}
BuildRequires: libcap-ng-devel >= 0.5.0
%endif
+%if %{with_fuse}
+BuildRequires: fuse-devel
+%endif
%if %{with_phyp}
BuildRequires: libssh2-devel
%endif
@@ -1157,6 +1161,10 @@ of recent versions of Linux (and other OSes).
%define _without_capng --without-capng
%endif
+%if ! %{with_fuse}
+%define _without_fuse --without-fuse
+%endif
+
%if ! %{with_netcf}
%define _without_netcf --without-netcf
%endif
@@ -1261,6 +1269,7 @@ autoreconf -if
%{?_without_numactl} \
%{?_without_numad} \
%{?_without_capng} \
+ %{?_without_fuse} \
%{?_without_netcf} \
%{?_without_selinux} \
%{?_with_selinux_mount} \
--
1.7.7.6
12 years, 2 months