[libvirt] snapshots += domain description?
by Philipp Hahn
Hello,
I just encountered a problem with the current snapshot implementation for
qemu/kvm: To revert back to a snapshot, the domain description must closely
match the domain description when the snapshot was created. If the ram-size
doesn't match or the VM now contains fewer CPUs or contains additional disks,
kvm will either not load the snapshot or the machine will be broken
afterwarts.
Is this a known problem?
Without looking into the implementation details I think saving the full domain
description instead of just a reference to the domain uuid as part of the
snapshot description would work better. Or am I supposed to save the domain
description myself in addition the the data saved
in /var/lib/libvirt/qemu/snapshot/$DOMAIN_NAME/$SNAPSHOT_NAME.xml. I think
this is very important feature, because when you - for example - notice that
you need additional disk space and would like to include an additional block
device, this is your ideal time to take a snapshot you can revert to when you
do something wrong.
Looking at VMware I see that reverting a VM there will not only revert the
disks and ram back to the saved state, but also the description including
name, ram size, etc.
Any comment or advise is appreciated.
Sincerely
Philipp Hahn
--
Philipp Hahn Open Source Software Engineer hahn(a)univention.de
Univention GmbH Linux for Your Business fon: +49 421 22 232- 0
Mary-Somerville-Str.1 28359 Bremen fax: +49 421 22 232-99
http://www.univention.de
13 years, 3 months
[libvirt] Is there smt missing at Java bindings?
by kadir yüceer
Hello all,
I've been posting questions about my issue to the user list but it seems
nobody can answer, so I had to try this list, sorry if there is any
disturbance.
Here is the case:
I've been trying to develop a java app that can register callbacks for
domain lifecycle events(suspend,resume,etc.). Only method that I've seen is
Connect.VirDomainEventRegisterAny, and there is an abstract callback method
inside VirConnectDomainEventGenericCallback. I implement the callback, and
register it for all the domains by passing the domain pointer as NULL.
Additionally for testing, I've added a println into the suspend function in
org.libvirt.Domain.java, and compiled the java bindings and used the new jar
file, and I was successful, I can see the message whenever I suspend the
domain either by clicking *pause* or by writing dom.suspend() in my java
app.
However, when I try to register a callback as I mentioned in the beginning
(with eventID 0, which is life_cycle ID), after the suspend operation, I get
the error that you can see at the end of the mail.
But before you check it out, I have to ask, are some of the event-related
features of libvirt missing in java bindings? For example;
VirEventAddHandleFunc, VirEventAddHandleCallback, and their derivatives. Is
this a problem or the only Connect.VirDomainEventRegisterAny method of java
binding suffice for providing callbacks for domain events?
Thanks in advance for your responses. The error is below.
Kind Regards
Kadir
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00000000, pid=5692, tid=3077520240
#
# JRE version: 6.0_20-b20
# Java VM: OpenJDK Server VM (19.0-b09 mixed mode linux-x86 )
# Derivative: IcedTea6 1.9.7
# Distribution: Ubuntu 10.10, package 6b20-1.9.7-0ubuntu1
# Problematic frame:
# C 0x00000000
#
# An error report file with more information is saved as:
# /root/NetBeansProjects/NovaTest_v0.3/hs_err_pid5692.log
#
# If you would like to submit a bug report, please include
# instructions how to reproduce the bug and visit:
# https://bugs.launchpad.net/ubuntu/+source/openjdk-6/
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
Java Result: 134
13 years, 3 months
[libvirt] [PATCH] qemu: Fix -chardev udp if parameters are omitted
by Cole Robinson
The following XML:
<serial type='udp'>
<source mode='connect' service='9999'/>
</serial>
is accepted by domain_conf.c but maps to the qemu command line:
-chardev udp,host=127.0.0.1,port=2222,localaddr=(null),localport=(null)
qemu can cope with everything omitting except the connection port, which
seems to also be the intent of domain_conf validation, so let's not
generate bogus command lines for that case.
Additionally, tweak the qemu cli parsing to handle omitted host parameters
for -serial udp
---
src/qemu/qemu_command.c | 48 +++++++++++---------
.../qemuxml2argv-serial-udp-chardev.args | 6 ++-
.../qemuxml2argv-serial-udp-chardev.xml | 4 ++
.../qemuxml2argvdata/qemuxml2argv-serial-udp.args | 2 +-
tests/qemuxml2argvdata/qemuxml2argv-serial-udp.xml | 4 ++
5 files changed, 39 insertions(+), 25 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index c9b9850..231d7c3 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -2119,14 +2119,17 @@ qemuBuildChrChardevStr(virDomainChrSourceDefPtr dev, const char *alias,
break;
case VIR_DOMAIN_CHR_TYPE_UDP:
- virBufferVSprintf(&buf,
- "udp,id=char%s,host=%s,port=%s,localaddr=%s,"
- "localport=%s",
+ virBufferVSprintf(&buf, "udp,id=char%s,port=%s",
alias,
- dev->data.udp.connectHost,
- dev->data.udp.connectService,
- dev->data.udp.bindHost,
- dev->data.udp.bindService);
+ dev->data.udp.connectService);
+
+ if (dev->data.udp.connectHost)
+ virBufferVSprintf(&buf, ",host=%s", dev->data.udp.connectHost);
+ if (dev->data.udp.bindHost)
+ virBufferVSprintf(&buf, ",localaddr=%s", dev->data.udp.bindHost);
+ if (dev->data.udp.bindService)
+ virBufferVSprintf(&buf, ",localport=%s",
+ dev->data.udp.bindService);
break;
case VIR_DOMAIN_CHR_TYPE_TCP:
@@ -2216,11 +2219,13 @@ qemuBuildChrArgStr(virDomainChrSourceDefPtr dev, const char *prefix)
break;
case VIR_DOMAIN_CHR_TYPE_UDP:
- virBufferVSprintf(&buf, "udp:%s:%s@%s:%s",
- dev->data.udp.connectHost,
- dev->data.udp.connectService,
- dev->data.udp.bindHost,
- dev->data.udp.bindService);
+ virBufferVSprintf(&buf, "udp:%s:%s",
+ dev->data.udp.connectHost ?: "",
+ dev->data.udp.connectService);
+ if (dev->data.udp.bindService)
+ virBufferVSprintf(&buf, "@%s:%s",
+ dev->data.udp.bindHost ?: "",
+ dev->data.udp.bindService);
break;
case VIR_DOMAIN_CHR_TYPE_TCP:
@@ -5302,13 +5307,12 @@ qemuParseCommandLineChr(const char *val)
host2 = svc1 ? strchr(svc1, '@') : NULL;
svc2 = host2 ? strchr(host2, ':') : NULL;
- if (svc1)
+ if (svc1 && (svc1 != val)) {
def->source.data.udp.connectHost = strndup(val, svc1-val);
- else
- def->source.data.udp.connectHost = strdup(val);
- if (!def->source.data.udp.connectHost)
- goto no_memory;
+ if (!def->source.data.udp.connectHost)
+ goto no_memory;
+ }
if (svc1) {
svc1++;
@@ -5323,14 +5327,14 @@ qemuParseCommandLineChr(const char *val)
if (host2) {
host2++;
- if (svc2)
+ if (svc2 && (svc2 != host2)) {
def->source.data.udp.bindHost = strndup(host2, svc2-host2);
- else
- def->source.data.udp.bindHost = strdup(host2);
- if (!def->source.data.udp.bindHost)
- goto no_memory;
+ if (!def->source.data.udp.bindHost)
+ goto no_memory;
+ }
}
+
if (svc2) {
svc2++;
def->source.data.udp.bindService = strdup(svc2);
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-serial-udp-chardev.args b/tests/qemuxml2argvdata/qemuxml2argv-serial-udp-chardev.args
index 7525110..8c6a6d5 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-serial-udp-chardev.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-udp-chardev.args
@@ -2,6 +2,8 @@ LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M \
pc -m 214 -smp 1 -nographic -nodefconfig -nodefaults -chardev socket,\
id=charmonitor,path=/tmp/test-monitor,server,nowait -mon chardev=charmonitor,\
id=monitor,mode=readline -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -chardev \
-udp,id=charserial0,host=127.0.0.1,port=9998,localaddr=127.0.0.1,localport=9999 \
--device isa-serial,chardev=charserial0,id=serial0 -usb -device \
+udp,id=charserial0,port=9998,host=127.0.0.1,localaddr=127.0.0.1,localport=9999 \
+-device isa-serial,chardev=charserial0,id=serial0 \
+-chardev udp,id=charserial1,port=9999 \
+-device isa-serial,chardev=charserial1,id=serial1 -usb -device \
virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-serial-udp-chardev.xml b/tests/qemuxml2argvdata/qemuxml2argv-serial-udp-chardev.xml
index 12622d4..9627c67 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-serial-udp-chardev.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-udp-chardev.xml
@@ -25,6 +25,10 @@
<source mode='connect' host='127.0.0.1' service='9998'/>
<target port='0'/>
</serial>
+ <serial type='udp'>
+ <source mode='connect' service='9999'/>
+ <target port='1'/>
+ </serial>
<console type='udp'>
<source mode='bind' host='127.0.0.1' service='9999'/>
<source mode='connect' host='127.0.0.1' service='9998'/>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-serial-udp.args b/tests/qemuxml2argvdata/qemuxml2argv-serial-udp.args
index 53c69bc..cf25fe0 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-serial-udp.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-udp.args
@@ -1,4 +1,4 @@
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M \
pc -m 214 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait \
-no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -serial \
-udp:127.0.0.1:9998@127.0.0.1:9999 -parallel none -usb
+udp:127.0.0.1:9998@127.0.0.1:9999 -serial udp::9999 -parallel none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-serial-udp.xml b/tests/qemuxml2argvdata/qemuxml2argv-serial-udp.xml
index 8697f5a..f606ea4 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-serial-udp.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-udp.xml
@@ -25,6 +25,10 @@
<source mode='connect' host='127.0.0.1' service='9998'/>
<target port='0'/>
</serial>
+ <serial type='udp'>
+ <source mode='connect' service='9999'/>
+ <target port='1'/>
+ </serial>
<console type='udp'>
<source mode='bind' host='127.0.0.1' service='9999'/>
<source mode='connect' host='127.0.0.1' service='9998'/>
--
1.7.4
13 years, 3 months
[libvirt] [BUG] Re: [2/6] loadvm: improve tests before bdrv_snapshot_goto()
by Philipp Hahn
Hello,
Am Dienstag 03 August 2010 06:44:26 schrieb Kevin Wolf:
> From: Miguel Di Ciurcio Filho <miguel.filho(a)gmail.com>
>
> This patch improves the resilience of the load_vmstate() function, doing
> further and better ordered tests.
This patch broke restoring not-running VMs using libvirt-0.8.7 with qemu-0.14:
When the domain is not running while taking a snpshot, the sn.vm_state_size
== 0:
2021 } else if (sn.vm_state_size == 0) {
(gdb) print sn
$6 = {id_str = "1", '\0' <repeats 126 times>, name = "pre-update-flash", '\0'
<repeats 239 times>, vm_state_size = 0, date_sec = 1302698007, date_nsec =
711909000,
vm_clock_nsec = 0}
> The [old] process:
...
> - run bdrv_snapshot_goto() on devices
> - if fails, give an warning and goes to the next (not good!)
> - if fails on the VM state device, return zero (not good!)
> - check if the requested snapshot exists on the device that saves the VM
> state and the state is not zero
> - if fails return -error
Previously the qcow2 image was still reverted to the old state, so on the next
start of the domain the qcow2 image would be in the state of the snapshot
> New behavior:
...
> - check if the requested snapshot exists on the device that saves the VM
> state and the state is not zero
> - if fails return -error
...
> - run snapshot_goto() on devices
Now the qcow2 image is not reverted and when the domain is started, it is NOT
in the state of the snapshot.
I can't decide if this regression is an Qemu bug or libvirt should be adapted
to this new behavior.
I found the Bug also reported with Ubuntu and created a Bug in our own German
bugtracker:
<https://bugs.launchpad.net/qemu/+bug/726619>
<https://forge.univention.org/bugzilla/show_bug.cgi?id=22221>
Sincerely
Philipp Hahn
--
Philipp Hahn Open Source Software Engineer hahn(a)univention.de
Univention GmbH Linux for Your Business fon: +49 421 22 232- 0
Mary-Somerville-Str.1 D-28359 Bremen fax: +49 421 22 232-99
http://www.univention.de/
13 years, 3 months
[libvirt] [PATCH 0/6] Add support for injecting NMI to guest
by Lai Jiangshan
This patch series implements a feature of injecting NMI to guest,
which is accessible via new virDomainInjectNMI API and
'inject-nmi' command in virsh.
Lai Jiangshan (6):
inject-nmi: Defining the public API
inject-nmi: Defining the internal API
inject-nmi: Implementing the public API
inject-nmi: Implementing the remote protocol
inject-nmi: Expose the new API in virsh
qemu,inject-nmi: Implement the driver methods
daemon/remote.c | 26 ++++++++++++++++++++
daemon/remote_dispatch_args.h | 1 +
daemon/remote_dispatch_prototypes.h | 8 ++++++
daemon/remote_dispatch_table.h | 5 ++++
include/libvirt/libvirt.h.in | 2 +
src/driver.h | 4 +++
src/esx/esx_driver.c | 1 +
src/libvirt.c | 44 +++++++++++++++++++++++++++++++++++
src/libvirt_public.syms | 5 ++++
src/libxl/libxl_driver.c | 1 +
src/lxc/lxc_driver.c | 1 +
src/openvz/openvz_driver.c | 1 +
src/phyp/phyp_driver.c | 3 +-
src/qemu/qemu_driver.c | 43 ++++++++++++++++++++++++++++++++++
src/qemu/qemu_monitor.c | 14 +++++++++++
src/qemu/qemu_monitor.h | 2 +
src/qemu/qemu_monitor_json.c | 29 +++++++++++++++++++++++
src/qemu/qemu_monitor_json.h | 1 +
src/qemu/qemu_monitor_text.c | 20 ++++++++++++++++
src/qemu/qemu_monitor_text.h | 1 +
src/remote/remote_driver.c | 25 +++++++++++++++++++
src/remote/remote_protocol.c | 11 ++++++++
src/remote/remote_protocol.h | 10 ++++++++
src/remote/remote_protocol.x | 8 +++++-
src/remote_protocol-structs | 4 +++
src/test/test_driver.c | 1 +
src/uml/uml_driver.c | 1 +
src/vbox/vbox_tmpl.c | 1 +
src/vmware/vmware_driver.c | 1 +
src/xen/xen_driver.c | 1 +
src/xen/xen_driver.h | 1 +
src/xen/xen_hypervisor.c | 1 +
src/xen/xen_inotify.c | 1 +
src/xen/xend_internal.c | 1 +
src/xen/xm_internal.c | 1 +
src/xen/xs_internal.c | 1 +
src/xenapi/xenapi_driver.c | 1 +
tools/virsh.c | 36 ++++++++++++++++++++++++++++
tools/virsh.pod | 4 +++
39 files changed, 320 insertions(+), 2 deletions(-)
--
1.7.4
13 years, 5 months
[libvirt] [libvirt-php] Work on ./example
by David Streibl
Hello,
as part of my student project I am working on simple web interface which
would support multiple virtualisation platforms.
This of course led me to libvirt and libvirt-php more specificly.
Right now I'm using modfied code of exapme Libvirt class and the plan is:
- add phpdoc
- refactor it to match libvirt convetion (get_domain_someting ->
dmain_get_something)
- split Libvirt to subclasses for domain, connection, network, storage (not
completly sure if it is good idea)
- add few unit tests (dont know about time and usefulness of this)
Would it be welcomed if I send to whole think or even parts of it as patches
to libvirt-php/example?
Thanks for any reply and sorry for my english,
David
13 years, 5 months
[libvirt] (how much) support for kqemu domain
by John Lumby
I am wondering about the extent to which "old" qemu-0.11.1 and kqemu-1.4.0 are supported by virt-manager.
I see I can specify --virt-type=kqemu on virt-install and it remembers domain type='kqemu', and does things such as refusing to start the vm if the kqemu kernel mod not loaded, but it seems it does not tack on the
-enable-kqemu -kernel-kqemu
options on to the qemu command line. There is really not much point in trying to start a qemu-based vm with neither hardware kvm nor kqemu ...
I can work around it with an override script to intercept the qemu command, but does anyone think virt-manager ought to do this for me?
John Lumby
_________________________________________________________________
13 years, 5 months
[libvirt] [PATCH RFC] Add domainSave/Restore to libxl driver
by Markus Groß
This patch adds save/restore functionality to the libxl driver.
It is a v2 of this patch:
https://www.redhat.com/archives/libvir-list/2011-April/msg00338.html
v2:
* header is now padded and has a version field
* the correct restore function from libxl is used
* only create the restore event once in libxlVmStart
However I ran into a reproducible segfault.
Assume you saved a vm with:
# virsh save domU foo.img
If you restore the save image,
destroy the vm and restore it again, a segfault occurs:
# virsh restore foo.img
# virsh destroy domU
# virsh restore foo.img
# segfault
If you restart libvirt between the restores no segfault occurs:
# virsh restore foo.img
# virsh destroy domU
# restart libvirt
# virsh restore foo.img
According to a gdb backtrace a memcpy from the function xc_domain_restore
is causing the segfault.
Then I saved a vm with the xl tool (which also uses the libxenlight interface)
and restored it twice. No segfault occured.
So I figured something must went wrong in libvirt.
However I was unable to identify the responsible part of code.
Now I am hoping that a review will possibly solve this issue.
Here is the gdb backtrace:
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x42ba1950 (LWP 23813)]
0x00007f1bc17d906b in memcpy () from /lib/libc.so.6
(gdb) bt
#0 0x00007f1bc17d906b in memcpy () from /lib/libc.so.6
#1 0x00007f1bc2b49346 in xc_domain_restore () from /usr/lib/libxenguest.so.4.0
#2 0x00007f1bc31a80f3 in ?? () from /usr/lib/libxenlight.so.1.0
#3 0x00007f1bc31a105e in ?? () from /usr/lib/libxenlight.so.1.0
#4 0x000000000049389a in libxlVmStart (driver=0x7f1bb8003e80, vm=0x7f1bb8053400, start_paused=false, restore_fd=20) at libxl/libxl_driver.c:531
#5 0x00000000004945c5 in libxlDomainRestore (conn=<value optimized out>, from=<value optimized out>) at libxl/libxl_driver.c:1745
#6 0x00007f1bc1f85a4b in virDomainRestore (conn=0x20a4d40, from=0x7f1bb804d260 "/root/tt.img") at libvirt.c:2330
#7 0x000000000042c5b8 in remoteDispatchDomainRestore (server=<value optimized out>, client=<value optimized out>, conn=0xaf0, hdr=<value optimized out>, rerr=0x42ba0e20,
args=0xffffffff, ret=0x42ba0f00) at remote.c:2616
#8 0x0000000000431cb7 in remoteDispatchClientRequest (server=0x209fe90, client=0x20a4ad0, msg=0x20b1aa0) at dispatch.c:524
#9 0x000000000041dd53 in qemudWorker (data=0x20a8018) at libvirtd.c:1622
#10 0x00007f1bc1cb9fc7 in start_thread () from /lib/libpthread.so.0
#11 0x00007f1bc182b64d in clone () from /lib/libc.so.6
#12 0x0000000000000000 in ?? ()
Cheers,
Markus
---
src/libxl/libxl_conf.h | 14 +++
src/libxl/libxl_driver.c | 228 ++++++++++++++++++++++++++++++++++++++++++----
2 files changed, 225 insertions(+), 17 deletions(-)
diff --git a/src/libxl/libxl_conf.h b/src/libxl/libxl_conf.h
index 8c87786..e7dd3a1 100644
--- a/src/libxl/libxl_conf.h
+++ b/src/libxl/libxl_conf.h
@@ -1,5 +1,6 @@
/*---------------------------------------------------------------------------*/
/* Copyright (c) 2011 SUSE LINUX Products GmbH, Nuernberg, Germany.
+ * Copyright (C) 2011 Univention GmbH.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -17,6 +18,7 @@
*
* Authors:
* Jim Fehlig <jfehlig(a)novell.com>
+ * Markus Groß <gross(a)univention.de>
*/
/*---------------------------------------------------------------------------*/
@@ -85,6 +87,18 @@ struct _libxlDomainObjPrivate {
int eventHdl;
};
+#define LIBXL_SAVE_MAGIC "libvirt-xml\n \0 \r"
+#define LIBXL_SAVE_VERSION 1
+
+typedef struct _libxlSavefileHeader libxlSavefileHeader;
+typedef libxlSavefileHeader *libxlSavefileHeaderPtr;
+struct _libxlSavefileHeader {
+ char magic[sizeof(LIBXL_SAVE_MAGIC)-1];
+ uint32_t version;
+ uint32_t xmlLen;
+ /* 24 bytes used, pad up to 64 bytes */
+ uint32_t unused[10];
+};
# define libxlError(code, ...) \
virReportErrorHelper(VIR_FROM_LIBXL, code, __FILE__, \
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 247d78e..56a62c9 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -29,6 +29,7 @@
#include <sys/utsname.h>
#include <math.h>
#include <libxl.h>
+#include <fcntl.h>
#include "internal.h"
#include "logging.h"
@@ -60,11 +61,10 @@
static libxlDriverPrivatePtr libxl_driver = NULL;
-
/* Function declarations */
static int
-libxlVmStart(libxlDriverPrivatePtr driver,
- virDomainObjPtr vm, bool start_paused);
+libxlVmStart(libxlDriverPrivatePtr driver, virDomainObjPtr vm,
+ bool start_paused, int restore_fd);
/* Function definitions */
@@ -188,7 +188,7 @@ libxlAutostartDomain(void *payload, const void *name ATTRIBUTE_UNUSED,
virResetLastError();
if (vm->autostart && !virDomainObjIsActive(vm) &&
- libxlVmStart(driver, vm, false) < 0) {
+ libxlVmStart(driver, vm, false, -1) < 0) {
err = virGetLastError();
VIR_ERROR(_("Failed to autostart VM '%s': %s"),
vm->def->name,
@@ -378,7 +378,7 @@ static void libxlEventHandler(int watch,
break;
case SHUTDOWN_reboot:
libxlVmReap(driver, vm, 0);
- libxlVmStart(driver, vm, 0);
+ libxlVmStart(driver, vm, 0, -1);
break;
default:
VIR_INFO("Unhandled shutdown_reason %d", info.shutdown_reason);
@@ -504,8 +504,8 @@ cleanup:
* virDomainObjPtr should be locked on invocation
*/
static int
-libxlVmStart(libxlDriverPrivatePtr driver,
- virDomainObjPtr vm, bool start_paused)
+libxlVmStart(libxlDriverPrivatePtr driver, virDomainObjPtr vm,
+ bool start_paused, int restore_fd)
{
libxl_domain_config d_config;
virDomainDefPtr def = vm->def;
@@ -524,12 +524,23 @@ libxlVmStart(libxlDriverPrivatePtr driver,
//TODO: Balloon dom0 ??
//ret = freemem(&d_config->b_info, &d_config->dm_info);
- ret = libxl_domain_create_new(&priv->ctx, &d_config,
- NULL, &child_console_pid, &domid);
+ if (restore_fd < 0)
+ ret = libxl_domain_create_new(&priv->ctx, &d_config,
+ NULL, &child_console_pid, &domid);
+ else
+ ret = libxl_domain_create_restore(&priv->ctx, &d_config, NULL,
+ &child_console_pid, &domid,
+ restore_fd);
+
if (ret) {
- libxlError(VIR_ERR_INTERNAL_ERROR,
- _("libxenlight failed to create new domain '%s'"),
- d_config.c_info.name);
+ if (restore_fd < 0)
+ libxlError(VIR_ERR_INTERNAL_ERROR,
+ _("libxenlight failed to create new domain '%s'"),
+ d_config.c_info.name);
+ else
+ libxlError(VIR_ERR_INTERNAL_ERROR,
+ _("libxenlight failed to restore domain '%s'"),
+ d_config.c_info.name);
goto error;
}
@@ -562,7 +573,9 @@ libxlVmStart(libxlDriverPrivatePtr driver,
goto error;
event = virDomainEventNewFromObj(vm, VIR_DOMAIN_EVENT_STARTED,
- VIR_DOMAIN_EVENT_STARTED_BOOTED);
+ restore_fd < 0 ?
+ VIR_DOMAIN_EVENT_STARTED_BOOTED :
+ VIR_DOMAIN_EVENT_STARTED_RESTORED);
libxlDomainEventQueue(driver, event);
libxl_domain_config_destroy(&d_config);
@@ -1046,7 +1059,8 @@ libxlDomainCreateXML(virConnectPtr conn, const char *xml,
goto cleanup;
def = NULL;
- if (libxlVmStart(driver, vm, (flags & VIR_DOMAIN_START_PAUSED) != 0) < 0) {
+ if (libxlVmStart(driver, vm, (flags & VIR_DOMAIN_START_PAUSED) != 0,
+ -1) < 0) {
virDomainRemoveInactive(&driver->domains, vm);
vm = NULL;
goto cleanup;
@@ -1566,6 +1580,186 @@ libxlDomainGetInfo(virDomainPtr dom, virDomainInfoPtr info)
}
static int
+libxlDomainSave(virDomainPtr dom, const char * to)
+{
+ libxlDriverPrivatePtr driver = dom->conn->privateData;
+ virDomainObjPtr vm;
+ libxlDomainObjPrivatePtr priv;
+ virDomainEventPtr event = NULL;
+ libxlSavefileHeader hdr;
+ libxl_domain_suspend_info s_info;
+ char *xml;
+ uint32_t xml_len;
+ int fd;
+ int ret = -1;
+
+ libxlDriverLock(driver);
+ vm = virDomainFindByUUID(&driver->domains, dom->uuid);
+
+ if (!vm) {
+ char uuidstr[VIR_UUID_STRING_BUFLEN];
+ virUUIDFormat(dom->uuid, uuidstr);
+ libxlError(VIR_ERR_NO_DOMAIN,
+ _("No domain with matching uuid '%s'"), uuidstr);
+ goto cleanup;
+ }
+
+ if (!virDomainObjIsActive(vm)) {
+ libxlError(VIR_ERR_OPERATION_INVALID, "%s", _("Domain is not running"));
+ goto cleanup;
+ }
+
+ priv = vm->privateData;
+
+ if (vm->state != VIR_DOMAIN_PAUSED) {
+ memset(&s_info, 0, sizeof(s_info));
+
+ if ((fd = virFileOpenAs(to, O_CREAT|O_TRUNC|O_WRONLY, S_IRUSR|S_IWUSR,
+ getuid(), getgid(), 0)) < 0) {
+ virReportSystemError(-fd,
+ _("Failed to create domain save file '%s'"),
+ to);
+ goto cleanup;
+ }
+
+ if ((xml = virDomainDefFormat(vm->def, 0)) == NULL)
+ goto cleanup;
+ xml_len = strlen(xml) + 1;
+
+ memset(&hdr, 0, sizeof(hdr));
+ memcpy(hdr.magic, LIBXL_SAVE_MAGIC, sizeof(hdr.magic));
+ hdr.version = LIBXL_SAVE_VERSION;
+ hdr.xmlLen = xml_len;
+
+ if (safewrite(fd, &hdr, sizeof(hdr)) != sizeof(hdr)) {
+ libxlError(VIR_ERR_OPERATION_FAILED,
+ _("Failed to write save file header"));
+ goto cleanup;
+ }
+
+ if (safewrite(fd, xml, xml_len) != xml_len) {
+ libxlError(VIR_ERR_OPERATION_FAILED,
+ _("Failed to write xml description"));
+ goto cleanup;
+ }
+
+ if (libxl_domain_suspend(&priv->ctx, &s_info, dom->id, fd) != 0) {
+ libxlError(VIR_ERR_INTERNAL_ERROR,
+ _("Failed to save domain '%d' with libxenlight"),
+ dom->id);
+ goto cleanup;
+ }
+
+ event = virDomainEventNewFromObj(vm, VIR_DOMAIN_EVENT_STOPPED,
+ VIR_DOMAIN_EVENT_STOPPED_SAVED);
+
+ if (libxlVmReap(driver, vm, 1) != 0) {
+ libxlError(VIR_ERR_INTERNAL_ERROR,
+ _("Failed to destroy domain '%d'"), dom->id);
+ goto cleanup;
+ }
+
+ if (!vm->persistent) {
+ virDomainRemoveInactive(&driver->domains, vm);
+ vm = NULL;
+ }
+ ret = 0;
+ }
+cleanup:
+ VIR_FREE(xml);
+ if (VIR_CLOSE(fd) < 0)
+ virReportSystemError(errno, "%s", _("cannot close file"));
+ if (vm)
+ virDomainObjUnlock(vm);
+ if (event)
+ libxlDomainEventQueue(driver, event);
+ libxlDriverUnlock(driver);
+ return ret;
+}
+
+static int
+libxlDomainRestore(virConnectPtr conn, const char * from)
+{
+ libxlDriverPrivatePtr driver = conn->privateData;
+ virDomainDefPtr def = NULL;
+ virDomainObjPtr vm = NULL;
+ libxlSavefileHeader hdr;
+ char *xml = NULL;
+ int fd;
+ int ret = -1;
+
+ libxlDriverLock(driver);
+
+ if ((fd = virFileOpenAs(from, O_RDONLY, 0, getuid(), getgid(), 0)) < 0) {
+ libxlError(VIR_ERR_OPERATION_FAILED,
+ "%s", _("cannot read domain image"));
+ goto cleanup;
+ }
+
+ if (saferead(fd, &hdr, sizeof(hdr)) != sizeof(hdr)) {
+ libxlError(VIR_ERR_OPERATION_FAILED,
+ "%s", _("failed to read libxl header"));
+ goto cleanup;
+ }
+
+ if (memcmp(hdr.magic, LIBXL_SAVE_MAGIC, sizeof(hdr.magic))) {
+ libxlError(VIR_ERR_INVALID_ARG, "%s", _("image magic is incorrect"));
+ goto cleanup;
+ }
+
+ if (hdr.version > LIBXL_SAVE_VERSION) {
+ libxlError(VIR_ERR_OPERATION_FAILED,
+ _("image version is not supported (%d > %d)"),
+ hdr.version, LIBXL_SAVE_VERSION);
+ goto cleanup;
+ }
+
+ if (hdr.xmlLen <= 0) {
+ libxlError(VIR_ERR_OPERATION_FAILED,
+ _("invalid XML length: %d"), hdr.xmlLen);
+ goto cleanup;
+ }
+
+ if (VIR_ALLOC_N(xml, hdr.xmlLen) < 0) {
+ virReportOOMError();
+ goto cleanup;
+ }
+
+ if (saferead(fd, xml, hdr.xmlLen) != hdr.xmlLen) {
+ libxlError(VIR_ERR_OPERATION_FAILED, "%s", _("failed to read XML"));
+ goto cleanup;
+ }
+
+ if (!(def = virDomainDefParseString(driver->caps, xml,
+ VIR_DOMAIN_XML_INACTIVE)))
+ goto cleanup;
+
+ if (virDomainObjIsDuplicate(&driver->domains, def, 1) < 0)
+ goto cleanup;
+
+ if (!(vm = virDomainAssignDef(driver->caps, &driver->domains, def, true)))
+ goto cleanup;
+
+ def = NULL;
+
+ if ((ret = libxlVmStart(driver, vm, false, fd)) < 0 &&
+ !vm->persistent) {
+ virDomainRemoveInactive(&driver->domains, vm);
+ vm = NULL;
+ }
+
+cleanup:
+ VIR_FREE(xml);
+ virDomainDefFree(def);
+ if (VIR_CLOSE(fd) < 0)
+ virReportSystemError(errno, "%s", _("cannot close file"));
+ if (vm)
+ virDomainObjUnlock(vm);
+ libxlDriverUnlock(driver);
+ return ret;
+}
+
+static int
libxlDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
unsigned int flags)
{
@@ -2036,7 +2230,7 @@ libxlDomainCreateWithFlags(virDomainPtr dom,
goto cleanup;
}
- ret = libxlVmStart(driver, vm, (flags & VIR_DOMAIN_START_PAUSED) != 0);
+ ret = libxlVmStart(driver, vm, (flags & VIR_DOMAIN_START_PAUSED) != 0, -1);
cleanup:
if (vm)
@@ -2672,8 +2866,8 @@ static virDriver libxlDriver = {
NULL, /* domainSetBlkioParameters */
NULL, /* domainGetBlkioParameters */
libxlDomainGetInfo, /* domainGetInfo */
- NULL, /* domainSave */
- NULL, /* domainRestore */
+ libxlDomainSave, /* domainSave */
+ libxlDomainRestore, /* domainRestore */
NULL, /* domainCoreDump */
libxlDomainSetVcpus, /* domainSetVcpus */
libxlDomainSetVcpusFlags, /* domainSetVcpusFlags */
--
1.7.1
13 years, 5 months
[libvirt] KVM Forum 2011: Call For Participation
by KVM-Forum-2011-PC@redhat.com
=================================================================
KVM Forum 2011: Call For Participation
August 15-16, 2011 - Hyatt Regency Vancouver - Vancouver, Canada
=================================================================
KVM is an industry leading open source hypervisor that provides an ideal
platform for datacenter virtualization, virtual desktop infrastructure,
and cloud computing. Once again, it's time to bring together the
community of developers and users that define the KVM ecosystem for
our annual technical conference. We will discuss the current state of
affairs and plan for the future of KVM, its surrounding infrastructure,
and management tools. So mark your calendar and join us in advancing KVM.
http://events.linuxfoundation.org/events/kvm-forum/
We are colocated with The Linux Foundation's LinuxCon again this year.
KVM Forum attendees will be eligible to attend LinuxCon for a discounted
rate.
http://events.linuxfoundation.org/events/kvm-forum/register
We invite you to lead part of the discussion by submitting a speaking
proposal for KVM Forum 2011.
http://events.linuxfoundation.org/cfp
Suggested topics:
KVM
- Scaling and performance
- Nested virtualization
- I/O improvements
- PCI device assignment
- Driver domains
- Time keeping
- Resource management (cpu, memory, i/o)
- Memory management (page sharing, swapping, huge pages, etc)
- Fault tolerance
- VEPA, VN-Link, vswitch
- Security
QEMU
- Device model improvements
- New devices
- Scaling and performance
- Desktop virtualization
- Spice
- Increasing robustness and hardening
- Security model
- Management interfaces
- QMP protocol and implementation
- Image formats
- Live migration
- Live snapshots and merging
Virtio
- Speeding up existing devices
- Alternatives
- Virtio on non-Linux
Management infrastructure
- Libvirt
- KVM autotest
- OpenStack
- Network virtualization management
- Enterprise storage management
Cloud computing
- Scalable storage
- Virtual networking
- Security
- Provisioning
- Hybrid
SUBMISSION REQUIREMENTS
Abstracts due: May 16th, 2011
Notification: May 31th, 2011
Please submit a short abstract (~150 words) describing your presentation
proposal. In your submission please note how long your talk will take.
Slots vary in length up to 45 minutes. Also include in your proposal
the proposal type -- one of:
- technical talk
- end-user talk
- BOF (birds of a feather) session
Sumbit your proposal here:
http://events.linuxfoundation.org/cfp
You will receive a notification whether or not your presentation proposal
was accepted by May 31st.
END-USER COLLABORATION
One of the big challenges as developers is to know what, where and how
people actually use our software. We will reserve a few slots for end
users talking about their deployment challenges and achievements.
If you are using KVM in production you are encouraged submit a speaking
proposal. Simply mark it as an end-user collaboration proposal. As and
end user, this is a unique opportunity to get your input to developers.
BOF SESSION
We will reserve some slots in the evening after the main conference
tracks, for birds of a feather sessions. These sessions will be less
formal than presentation tracks and targetted for people who would
like to discuss specific issues with other developers and/or users.
If you are interested in getting developers and/or uses together to
discuss a specific problem, please submit a BOF proposal.
LIGHTNING TALKS
In addition to submitted talks we will also have some room for lightning
talks. These are short (5 minute) discussions to highlight new work or
ideas that aren't complete enough to warrant a full presentation slot.
Lightning talk submissions and scheduling will be handled on-site at
KVM Forum.
HOTEL / TRAVEL
The KVM Forum 2011 will be held in Vancouver BC at the Hyatt Regency
Vancouver.
http://events.linuxfoundation.org/events/kvm-forum/travel
Thank you for your interest in KVM. We're looking forward to your
submissions and seeing you at the KVM Forum 2011 in August!
Thanks,
your KVM Forum 2011 Program Commitee
Please contact us with any questions or comments.
KVM-Forum-2011-PC(a)redhat.com
13 years, 6 months
[libvirt] [PATCH 0/6] Add disk streaming API to libvirt
by Adam Litke
I've been working with Anthony Liguori and Stefan Hajnoczi to enable data
streaming to copy-on-read disk images in qemu. This work is working its way
through review and I expect it to be upstream soon as part of the support for
the new QED disk image format.
Disk streaming is extremely useful when provisioning domains from a central
repository of template images. Currently the domain must be provisioned by
either: 1) copying the template image to local storage before the VM can be
started or, 2) creating a qcow2 image that backs to a base image in the remote
repository. Option 1 can introduce a significant delay when provisioning large
disks. Option 2 introduces a permanent dependency on a remote service and
increased network load to satisfy disk reads.
Device streaming provides the "instant-on" benefits of option 2 without
introducing a permanent dependency to the image repository. Once the VM is
started, the contents of the disk can be streamed to the local image in
parallel. Once streaming is finished, the domain has a complete and coherent
copy of the image and no longer depends on the central image repository.
Qemu will support two streaming modes: full device and single sector. Full
device streaming is the easiest to use because one command will cause the whole
device to be streamed as fast as possible. Single sector mode can be used if
one wants to throttle streaming to reduce I/O pressure. In this mode, a
management tool issues individual commands to stream single sectors.
To enable this support in libvirt, I propose the following API...
virDomainStreamDisk() will start or stop a full device stream or stream a
single sector of a device. The behavior is controlled by setting
virDomainStreamDiskFlags. When either starting or stopping a full device
stream, the return value is either 0 or -1 to indicate whether the operation
succeeded. For a single sector stream, a device offset is returned (or -1 on
failure). This value can be used to continue streaming with a subsequent call
to virDomainStreamDisk().
virDomainStreamDiskInfo() returns information about active full device streams
(the device alias, current streaming position, and total size).
Adam Litke (6):
Add new API virDomainStreamDisk[Info] to header and drivers
virDomainStreamDisk: Add public symbols to libvirt API
Implement disk streaming in the qemu driver
Add disk streaming support to the remote driver
Add new disk streaming commands to virsh
python: Add python bindings for virDomainStreamDisk[Info]
b/daemon/remote.c | 96 ++++++++++++++++++++
b/daemon/remote_dispatch_args.h | 2
b/daemon/remote_dispatch_prototypes.h | 16 +++
b/daemon/remote_dispatch_ret.h | 2
b/daemon/remote_dispatch_table.h | 10 ++
b/include/libvirt/libvirt.h.in | 34 +++++++
b/python/generator.py | 4
b/python/libvirt-override-api.xml | 5 +
b/python/libvirt-override.c | 46 +++++++++
b/src/driver.h | 11 ++
b/src/esx/esx_driver.c | 2
b/src/libvirt.c | 115 ++++++++++++++++++++++++
b/src/libvirt_public.syms | 5 +
b/src/lxc/lxc_driver.c | 2
b/src/openvz/openvz_driver.c | 2
b/src/phyp/phyp_driver.c | 2
b/src/qemu/qemu_driver.c | 77 +++++++++++++++-
b/src/qemu/qemu_monitor.c | 42 ++++++++
b/src/qemu/qemu_monitor.h | 6 +
b/src/qemu/qemu_monitor_json.c | 108 ++++++++++++++++++++++
b/src/qemu/qemu_monitor_json.h | 7 +
b/src/qemu/qemu_monitor_text.c | 162 ++++++++++++++++++++++++++++++++++
b/src/qemu/qemu_monitor_text.h | 8 +
b/src/remote/remote_driver.c | 87 +++++++++++++++++-
b/src/remote/remote_protocol.c | 63 +++++++++++++
b/src/remote/remote_protocol.h | 51 ++++++++++
b/src/remote/remote_protocol.x | 37 +++++++
b/src/test/test_driver.c | 2
b/src/uml/uml_driver.c | 2
b/src/vbox/vbox_tmpl.c | 2
b/src/vmware/vmware_driver.c | 2
b/src/xen/xen_driver.c | 2
b/tools/virsh.c | 134 +++++++++++++++++++++++++++-
python/generator.py | 3
src/qemu/qemu_driver.c | 2
src/remote/remote_driver.c | 2
36 files changed, 1144 insertions(+), 9 deletions(-)
13 years, 6 months