[libvirt] Local storage-migration plus network disks (Ceph RBD)
by Blair Bethwaite
Hi there,
We have a production OpenStack cloud, currently on Qemu 1.0 & 1.5 with
Libivrt 1.1.1. We're using local storage with storage-migration when
we need to move machines around.
Since we built this thing we've noticed that with network storage
attached (have seen this with iSCSI and Ceph RBD targets, mainly
interested in the latter) the migration moves all of the network disk
contents as well, which for any non-toy disk sizes pretty much renders
it useless as the migration is then bounded not by the guest memory
size and activity but also by the block storage size. E.g., an idle
guest with 8GB RAM and a 300GB Ceph RBD attached takes ~3 hours to
migrate (over a 20GE network) and we observe balanced TX/RX on both
the source and destination, as the source reads blocks from the Ceph
cluster, streams them to the destination, and the destination in turn
writes them back to the Ceph cluster.
Looking in Libvirt's qemu_migration.c code I see
qemuMigrationDriveMirror skips shared, RO and source-less disks. But
I'm not sure why network disks in general, and in particular RBDs,
wouldn't be considered shared for these purposes. From my naive
reading the checks in qemuMigrationIsSafe (which explicitly pass
NETWORK+RBD) seem to confirm this, at least for RBDs. Is this a bug?
--
Cheers,
~Blairo
10 years, 7 months
[libvirt] [PATCH perl-Sys-Virt] Don't die if snapshots are unsupported
by Mike Latimer
Many libvirt-tck tests do not explicitly cleanup test domains before exiting.
In this case Sys::Virt::TCK->cleanup is triggered, and the environment is
reset automatically. During this reset, any existing snapshots are found for
deletion through Sys::Virt::Domain->list_snapshots. If the underlying
connection driver does not support snapshot functions (such as lxc or libxl),
the process dies with the following error:
libvirt error code: 3, message: this function is not supported by the
connection driver: virDomainSnapshotListNames
The best resolution would be to add snapshot support to the driver(s), but as
this requires a long term effort, it is better to catch the error and return
an empty list of snapshots to the calling function. In the case of
libvirt-tck, this allows the cleanup to succeed and subsequent testing to
continue normally.
---
Domain.pm | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
--- a/lib/Sys/Virt/Domain.pm 2014-04-07 04:35:31.000000000 -0600
+++ b/lib/Sys/Virt/Domain.pm 2014-04-21 13:48:22.868956838 -0600
@@ -1416,7 +1416,10 @@ recommended as a more efficient alternat
sub list_snapshots {
my $self = shift;
- my $nnames = $self->num_of_snapshots();
+ # If snapshots are not supported by the driver (lxc, libxl...), catch the
+ # function not supported error and simply return as there are no snapshots
+ my $nnames = eval { $self->num_of_snapshots() };
+ return if($@ =~ /function is not supported/);
my @names = $self->list_snapshot_names($nnames);
my @snapshots;
10 years, 7 months
[libvirt] [PATCH] nodeinfo: fix detection of physical memory on uclibc/musl libc
by Natanael Copa
The gnulib's physmem_total will as a fallback report 64MB as total
memory if sysconf(_SC_PHYS_PAGES) is unimplemented on linux. This makes
it impossible to detect if physmem_total works or not, so we try first
the linux only sysinfo(2) before falling back to gnulibs physmem_total.
This makes the total memory be correctly reported on musl libc and
uclibc.
Signed-off-by: Natanael Copa <ncopa(a)alpinelinux.org>
---
configure.ac | 2 +-
src/nodeinfo.c | 22 ++++++++++++++++------
2 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/configure.ac b/configure.ac
index 52c50df..32a2e5a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -310,7 +310,7 @@ dnl Availability of various common headers (non-fatal if missing).
AC_CHECK_HEADERS([pwd.h paths.h regex.h sys/un.h \
sys/poll.h syslog.h mntent.h net/ethernet.h linux/magic.h \
sys/un.h sys/syscall.h sys/sysctl.h netinet/tcp.h ifaddrs.h \
- libtasn1.h sys/ucred.h sys/mount.h])
+ libtasn1.h sys/ucred.h sys/mount.h sys/sysinfo.h])
dnl Check whether endian provides handy macros.
AC_CHECK_DECLS([htole64], [], [], [[#include <endian.h>]])
diff --git a/src/nodeinfo.c b/src/nodeinfo.c
index c88f86c..3c76f54 100644
--- a/src/nodeinfo.c
+++ b/src/nodeinfo.c
@@ -40,6 +40,10 @@
# include <sys/resource.h>
#endif
+#if HAVE_SYS_SYSINFO_H
+# include <sys/sysinfo.h>
+#endif
+
#include "c-ctype.h"
#include "viralloc.h"
#include "nodeinfopriv.h"
@@ -1041,7 +1045,18 @@ int nodeGetInfo(virNodeInfoPtr nodeinfo)
#ifdef __linux__
{
int ret = -1;
- FILE *cpuinfo = fopen(CPUINFO_PATH, "r");
+ FILE *cpuinfo;
+#if HAVE_SYS_SYSINFO_H
+ struct sysinfo si;
+
+ /* Convert to KB. */
+ if (sysinfo(&si) == 0) {
+ nodeinfo->memory = si.totalram / 1024;
+ } else
+#endif
+ nodeinfo->memory = physmem_total() / 1024;
+
+ cpuinfo = fopen(CPUINFO_PATH, "r");
if (!cpuinfo) {
virReportSystemError(errno,
_("cannot open %s"), CPUINFO_PATH);
@@ -1049,11 +1064,6 @@ int nodeGetInfo(virNodeInfoPtr nodeinfo)
}
ret = linuxNodeInfoCPUPopulate(cpuinfo, SYSFS_SYSTEM_PATH, nodeinfo);
- if (ret < 0)
- goto cleanup;
-
- /* Convert to KB. */
- nodeinfo->memory = physmem_total() / 1024;
cleanup:
VIR_FORCE_FCLOSE(cpuinfo);
--
1.9.2
10 years, 7 months
[libvirt] [PATCH 0/3] vcpu fixes
by Ján Tomko
Ján Tomko (3):
Properly free vcpupin info for unplugged CPUs
Make virDomainVcpuPinDel return void
Fix error for out of range vcpu in qemuDomainPinVcpuFlags
src/conf/domain_conf.c | 31 ++-----------------------------
src/conf/domain_conf.h | 5 +----
src/libvirt_private.syms | 1 -
src/libxl/libxl_driver.c | 7 +------
src/qemu/qemu_driver.c | 22 ++++------------------
5 files changed, 8 insertions(+), 58 deletions(-)
--
1.8.3.2
10 years, 7 months
[libvirt] Proper behavior when "creating" a new transient domain with same name/uuid as existing persistent domain
by Laine Stump
Playing around with the network driver I found that if I net-define a
network, then net-create using a slightly modified version of the same
XML file (e.g. different bridge name, but same name/uuid) the following
will happen:
1) a network of that name is started, it is persistent, and it has the
properties from the modified XML file (the one given to net-create).
2) both "net-dumpxml" and "net-dumpxml --inactive" will show the
modified attributes.
3) when I net-destroy the network, the network will still exist (since
it is still persistent), but will have all of the modified attributes
rather than the originals.
Wanting the network driver to behave consistently with the qemu driver,
I did the same test with a qemu domain. I found exactly the same behavior.
I would have expected that when I tried to create a domain (or network)
with the same name & UUID as an existing persistent&inactive domain (or
network) that one of the following two things would happen:
1) the operation would fail because a persistent domain/network already
existed
2) the domain/network would be started with the modified attributes, but
the persistent definition would still show the original attributes,
which would remain after destroying the transient
3) upon creating the transient version, the domain/network would have
its persistent flag cleared, and would thus cease to exist when destroyed.
Was the current behavior consciously arrived at, or is it just an
accident of circumstances? If the latter, then what should the proper
behavior be? (I would vote for (2))
10 years, 7 months
[libvirt] [PATCH v2] Add support for migration URI configuration
by Chen Fan
For now, we set the migration URI from command line '--migrate_uri' or
construct the URI by looking up the dest host's hostname which could be
solved by DNS automatically.
But in cases the dest host have two or more NICs to reach, we may need to
send the migration data over a specific NIC which is different from the
automatically resloved one for some reason like performance, security, etc.
thus we must explicitly specify the migrateuri in command line everytime,
but it is too troublesome if there are many such hosts(and don't forget
virt-manager).
This patch adds a configuration file option on dest host to save the
default migrate uri which explicitly configure which of this host's
addresses should be used to transfer, thus user doesn't boring to specify
it in command line everytime.
Signed-off-by: Chen Fan <chen.fan.fnst(a)cn.fujitsu.com>
---
src/qemu/qemu.conf | 5 ++++-
src/qemu/qemu_conf.c | 2 ++
src/qemu/qemu_conf.h | 2 ++
src/qemu/qemu_migration.c | 5 +++++
4 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf
index f0e802f..2973631 100644
--- a/src/qemu/qemu.conf
+++ b/src/qemu/qemu.conf
@@ -449,7 +449,10 @@
#
#seccomp_sandbox = 1
-
+# Override the URI used for any specific migration URI to be sent.
+# Defaults to NULL, will be set to as "tcp://hostIP[:port]".
+#
+#migrate_uri = "tcp://hostIP:port"
# Override the listen address for all incoming migrations. Defaults to
# 0.0.0.0, or :: if both host and qemu are capable of IPv6.
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 198ee2f..0bd943d 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -576,6 +576,8 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr cfg,
GET_VALUE_STR("migration_address", cfg->migrationAddress);
+ GET_VALUE_STR("migrate_uri", cfg->migrateUri);
+
ret = 0;
cleanup:
diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
index a36ea63..2e45421 100644
--- a/src/qemu/qemu_conf.h
+++ b/src/qemu/qemu_conf.h
@@ -167,6 +167,8 @@ struct _virQEMUDriverConfig {
char *migrationAddress;
int migrationPortMin;
int migrationPortMax;
+
+ char *migrateUri;
};
/* Main driver state */
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 593d2d3..ab64c58 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -2639,6 +2639,7 @@ qemuMigrationPrepareDirect(virQEMUDriverPtr driver,
int ret = -1;
virURIPtr uri = NULL;
bool well_formed_uri = true;
+ virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
VIR_DEBUG("driver=%p, dconn=%p, cookiein=%s, cookieinlen=%d, "
"cookieout=%p, cookieoutlen=%p, uri_in=%s, uri_out=%p, "
@@ -2649,6 +2650,10 @@ qemuMigrationPrepareDirect(virQEMUDriverPtr driver,
*uri_out = NULL;
+ if (uri_in == NULL && cfg->migrateUri) {
+ uri_in = cfg->migrateUri;
+ }
+
/* The URI passed in may be NULL or a string "tcp://somehostname:port".
*
* If the URI passed in is NULL then we allocate a port number
--
1.8.1.4
10 years, 7 months
[libvirt] [test-API][PATCH V2 0/2] Add case for setSchedulerParametersFlag API
by Xuesong Zhang
V1->V2:
Delete the symbol '\' at the end of lines.
Update the domian stats to "libvirt.VIR_DOMAIN_RUNNING" and
"libvirt.VIR_DOMAIN_SHUTOFF", instead of the
static value.
Delete the scenario without flags in file shed_parms.conf
V1:
Add test case for setSchedulerParametersFlags related API
Add conf file of setSchedulerParametersFlags test
Xuesong Zhang (2):
Add new cases for testing setSchedulerParametersFlags related API
Add scenario conf file for testing setSchedulerParametersFlags related
API
cases/sched_params.conf | 106 ++++++++++++++++++++++++++
repos/domain/sched_params_flag.py | 155 ++++++++++++++++++++++++++++++++++++++
2 files changed, 261 insertions(+)
create mode 100755 cases/sched_params.conf
create mode 100755 repos/domain/sched_params_flag.py
--
1.8.3.1
10 years, 7 months
[libvirt] libvirt-libxl driver defaulting to tap disk and not working (ubuntu 12.10 + xen 4.5 + libvirt 1.2.3 + openstack)
by Tian, Shuangtai
HI
I am an openstacker, when I used the latest libvirt and xen code to run the openstack. Can not create the vm.
there is an error in libxl log, you can see the log:
Os : Ubuntu 12.10
Compiled against library: libvirt 1.2.3
Using library: libvirt 1.2.3
Using API: Xen 1.2.3
Running hypervisor: Xen 4.5.0
libxl: debug: libxl_create.c:1356:do_domain_create: ao 0x7f7894002810: create: how=(nil) callback=(nil) poller=0x7f7894001bb0
libxl: debug: libxl_device.c:251:libxl__device_disk_set_backend: Disk vdev=xvda spec.backend=tap
libxl: debug: libxl_device.c:210:disk_try_backend: Disk vdev=xvda, backend tap unsuitable because blktap not available
libxl: error: libxl_device.c:289:libxl__device_disk_set_backend: no suitable backend for disk xvda
libxl: debug: libxl_event.c:1739:libxl__ao_complete: ao 0x7f7894002810: complete, rc=-3
libxl: debug: libxl_create.c:1370:do_domain_create: ao 0x7f7894002810: inprogress: poller=0x7f7894001bb0, flags=ic
libxl: debug: libxl_event.c:1711:libxl__ao__destroy: ao 0x7f7894002810: destroy
The blktap does work, and I also find the same error someone has posted, (http://www.redhat.com/archives/libvir-list/2013-February/msg01124.html)
When I change the type to "phy", it also doesnot work. And try to change the type to other options, also does not work.
Can someone give me some suggestions?
Thanks !
The XML from the openstack is :
<domain type="xen">
<uuid>9e9ed86c-8892-40da-acd1-31ec6303abfe</uuid>
<name>instance-00000001</name>
<memory>524288</memory>
<vcpu>1</vcpu>
<os>
<type>xen</type>
<kernel>/opt/stack/data/nova/instances/9e9ed86c-8892-40da-acd1-31ec6303abfe/kernel</kernel>
<initrd>/opt/stack/data/nova/instances/9e9ed86c-8892-40da-acd1-31ec6303abfe/ramdisk</initrd>
<cmdline>ro root=/dev/xvda</cmdline>
</os>
<features>
<acpi/>
<apic/>
</features>
<clock offset="utc"/>
<devices>
<disk type="file" device="disk">
<driver name="tap2" type="raw" cache="none"/>
<source file="/opt/stack/data/nova/instances/9e9ed86c-8892-40da-acd1-31ec6303abfe/disk"/>
<target bus="xen" dev="xvda"/>
</disk>
<disk type="file" device="cdrom">
<driver name="tap2" type="raw" cache="none"/>
<source file="/opt/stack/data/nova/instances/9e9ed86c-8892-40da-acd1-31ec6303abfe/disk.config"/>
<target bus="ide" dev="xvdd"/>
</disk>
<interface type="bridge">
<mac address="fa:16:3e:d8:c3:c0"/>
<source bridge="br100"/>
<filterref filter="nova-instance-instance-00000001-fa163ed8c3c0"/>
</interface>
<console type="pty"/>
<graphics type="vnc" autoport="yes" keymap="en-us" listen="127.0.0.1"/>
<video>
<model type="xen"/>
</video>
</devices>
</domain>
Best regards,
Tian, Shuangtai
10 years, 7 months
[libvirt] [PATCH] qemu: don't check for backing chains for formats w/o snapshot support
by Martin Kletzander
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1019926
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=868673
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
src/libvirt_private.syms | 2 +-
src/qemu/qemu_domain.c | 3 +++
src/util/virstoragefile.c | 15 +++++++++++++++
src/util/virstoragefile.h | 2 ++
4 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 0e81f2f..42c0185 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1834,6 +1834,7 @@ virStorageFileIsClusterFS;
virStorageFileProbeFormat;
virStorageFileProbeFormatFromBuf;
virStorageFileResize;
+virStorageFormatMaySupportSnapshots;
virStorageIsFile;
virStorageNetHostDefClear;
virStorageNetHostDefCopy;
@@ -1850,7 +1851,6 @@ virStorageSourcePoolModeTypeToString;
virStorageTypeFromString;
virStorageTypeToString;
-
# util/virstring.h
virArgvToString;
virAsprintfInternal;
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index cdd4601..abc2a68 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -2250,6 +2250,9 @@ qemuDomainCheckDiskPresence(virQEMUDriverPtr driver,
if (!virDomainDiskGetSource(disk))
continue;
+ if (!virStorageFormatMaySupportSnapshots(disk->src.format))
+ continue;
+
if (qemuDomainDetermineDiskChain(driver, vm, disk, false) >= 0 &&
qemuDiskChainCheckBroken(disk) >= 0)
continue;
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index ea80c1d..c781a6b 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -1730,3 +1730,18 @@ virStorageSourceClear(virStorageSourcePtr def)
virStorageNetHostDefFree(def->nhosts, def->hosts);
virStorageSourceAuthClear(def);
}
+
+bool
+virStorageFormatMaySupportSnapshots(enum virStorageFileFormat format)
+{
+ if (format == VIR_STORAGE_FILE_AUTO ||
+ format == VIR_STORAGE_FILE_AUTO_SAFE)
+ return true;
+
+ /* Better safe than sorry */
+ if (format <= VIR_STORAGE_FILE_NONE ||
+ format >= VIR_STORAGE_FILE_LAST)
+ return false;
+
+ return !!fileTypeInfo[format].getBackingStore;
+}
diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h
index 1b8b14f..bcbfb88 100644
--- a/src/util/virstoragefile.h
+++ b/src/util/virstoragefile.h
@@ -339,4 +339,6 @@ void virStorageSourcePoolDefFree(virStorageSourcePoolDefPtr def);
void virStorageSourceClear(virStorageSourcePtr def);
int virStorageSourceGetActualType(virStorageSourcePtr def);
+bool virStorageFormatMaySupportSnapshots(enum virStorageFileFormat format);
+
#endif /* __VIR_STORAGE_FILE_H__ */
--
1.9.2
10 years, 7 months
[libvirt] [PATCH 1/2] util: introduce virDirRead wrapper for readdir
by Natanael Copa
Introduce a wrapper for readdir. This helps us make sure that we always
set errno before calling readdir and it will make sure errors are
properly logged.
Signed-off-by: Natanael Copa <ncopa(a)alpinelinux.org>
---
src/util/virfile.c | 14 ++++++++++++++
src/util/virfile.h | 3 +++
2 files changed, 17 insertions(+)
diff --git a/src/util/virfile.c b/src/util/virfile.c
index 3eb2703..b54b9fd 100644
--- a/src/util/virfile.c
+++ b/src/util/virfile.c
@@ -2295,6 +2295,20 @@ virDirCreate(const char *path ATTRIBUTE_UNUSED,
}
#endif /* WIN32 */
+/* return 0 = success, 1 = end-of-dir and -1 = error */
+int virDirRead(DIR *dirp, struct dirent **ent, const char *dirname)
+{
+ errno = 0;
+ *ent = readdir(dirp);
+ if (!*ent && errno) {
+ if (dirname)
+ virReportSystemError(errno, _("Unable to read directory '%s'"),
+ dirname);
+ return -1;
+ }
+ return !*ent;
+}
+
static int
virFileMakePathHelper(char *path, mode_t mode)
{
diff --git a/src/util/virfile.h b/src/util/virfile.h
index 46ef781..622a81b 100644
--- a/src/util/virfile.h
+++ b/src/util/virfile.h
@@ -27,6 +27,7 @@
# define __VIR_FILE_H_
# include <stdio.h>
+# include <dirent.h>
# include "internal.h"
# include "virstoragefile.h"
@@ -211,6 +212,8 @@ enum {
};
int virDirCreate(const char *path, mode_t mode, uid_t uid, gid_t gid,
unsigned int flags) ATTRIBUTE_RETURN_CHECK;
+int virDirRead(DIR *dirp, struct dirent **ent, const char *dirname);
+
int virFileMakePath(const char *path) ATTRIBUTE_RETURN_CHECK;
int virFileMakePathWithMode(const char *path,
mode_t mode) ATTRIBUTE_RETURN_CHECK;
--
1.9.2
10 years, 7 months