[libvirt] add optional redundancy element to storage
by Vasiliy Tolstov
some storages have ability to provide redundancy, for
example sheepdog via full copies or erasure
Signed-off-by: Vasiliy Tolstov <v.tolstov(a)selfip.ru>
---
docs/schemas/storagevol.rng | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/docs/schemas/storagevol.rng b/docs/schemas/storagevol.rng
index 7450547..bd3b698 100644
--- a/docs/schemas/storagevol.rng
+++ b/docs/schemas/storagevol.rng
@@ -105,6 +105,9 @@
</choice>
</element>
</optional>
+ <optional>
+ <ref name='redundancy'/>
+ </optional>
<ref name='format'/>
<ref name='permissions'/>
<ref name='timestamps'/>
@@ -138,6 +141,27 @@
</element>
</define>
+ <define name='redundancy'>
+ <optional>
+ <element name='replica'>
+ <element name='copies'>
+ <ref name='scaledInteger'/>
+ </element>
+ </element>
+ </optional>
+ <optional>
+ <element name='erasure'>
+ <element name='strips'>
+ <attribute name='data'>
+ <ref name='scaledInteger'/>
+ </attribute>
+ <attribute name='parity'>
+ <ref name='scaledInteger'/>
+ </attribute>
+ </element>
+ </element>
+ </optional>
+ </define>
<define name='source'>
<element name='source'>
--
2.3.3
9 years, 4 months
[libvirt] [sandbox] Cleanup the disks.cfg file
by Cédric Bosdonnat
The newly introduced disks.cfg file is still remaining in the
configuration folder after the sandbox is stopped. Let's remove it like
the other things there.
---
libvirt-sandbox/libvirt-sandbox-builder.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/libvirt-sandbox/libvirt-sandbox-builder.c b/libvirt-sandbox/libvirt-sandbox-builder.c
index e615606..ea7d064 100644
--- a/libvirt-sandbox/libvirt-sandbox-builder.c
+++ b/libvirt-sandbox/libvirt-sandbox-builder.c
@@ -22,6 +22,7 @@
#include <config.h>
#include <string.h>
+#include <errno.h>
#include "libvirt-sandbox/libvirt-sandbox.h"
#include "libvirt-sandbox/libvirt-sandbox-builder-private.h"
@@ -717,10 +718,15 @@ gboolean gvir_sandbox_builder_clean_post_stop(GVirSandboxBuilder *builder,
GFileEnumerator *enumerator = NULL;
GFileInfo *info = NULL;
GFile *child = NULL;
+ gchar *dskfile = g_build_filename(statedir, "config", "disks.cfg", NULL);
gboolean ret = TRUE;
ret = klass->clean_post_stop(builder, config, statedir, error);
+ if (unlink(dskfile) < 0 &&
+ errno != ENOENT)
+ ret = FALSE;
+
if (!(enumerator = g_file_enumerate_children(libsFile, "*", G_FILE_QUERY_INFO_NONE,
NULL, error)) &&
(*error)->code != G_IO_ERROR_NOT_FOUND) {
--
2.1.4
9 years, 4 months
[libvirt] [PATCH] qemu: fix not end the job after use OpenGraphics(FD) and get fail when exit monitor
by Luyao Huang
If guest unexpect exit(qemu process be killed) and get failed when
exit the monitor, guest job still handled by old function, this will
make guest cannot start later.
Need call qemuDomainObjEndJob to release job status before unref vm.
Signed-off-by: Luyao Huang <lhuang(a)redhat.com>
---
src/qemu/qemu_driver.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 2b530c8..b1c9f08 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -17255,10 +17255,8 @@ qemuDomainOpenGraphics(virDomainPtr dom,
qemuDomainObjEnterMonitor(driver, vm);
ret = qemuMonitorOpenGraphics(priv->mon, protocol, fd, "graphicsfd",
(flags & VIR_DOMAIN_OPEN_GRAPHICS_SKIPAUTH) != 0);
- if (qemuDomainObjExitMonitor(driver, vm) < 0) {
+ if (qemuDomainObjExitMonitor(driver, vm) < 0)
ret = -1;
- goto cleanup;
- }
qemuDomainObjEndJob(driver, vm);
cleanup:
@@ -17327,10 +17325,8 @@ qemuDomainOpenGraphicsFD(virDomainPtr dom,
qemuDomainObjEnterMonitor(driver, vm);
ret = qemuMonitorOpenGraphics(priv->mon, protocol, pair[1], "graphicsfd",
(flags & VIR_DOMAIN_OPEN_GRAPHICS_SKIPAUTH));
- if (qemuDomainObjExitMonitor(driver, vm) < 0) {
+ if (qemuDomainObjExitMonitor(driver, vm) < 0)
ret = -1;
- goto cleanup;
- }
qemuDomainObjEndJob(driver, vm);
if (ret < 0)
goto cleanup;
--
1.8.3.1
9 years, 4 months
[libvirt] [PATCH 0/2] conf: qemu: Fix memory auditing
by Peter Krempa
Peter Krempa (2):
conf: audit: Audit physical memory size rather than balloon request
qemu: Audit memory size with memory hotplug operations
src/conf/domain_audit.c | 3 ++-
src/qemu/qemu_driver.c | 6 +-----
src/qemu/qemu_hotplug.c | 20 ++++++++++++++------
3 files changed, 17 insertions(+), 12 deletions(-)
--
2.4.1
9 years, 4 months
[libvirt] sheepdog volume and number of copies
by Vasiliy Tolstov
Hi libvirt devs!
Sheepdog have ability to specify number of copies (full replica or
erasure) for each vdi when it created,
Now xml looks like:
<volume>
<name>{VDI_NAME}</name>
<key>sheep/{VDI_NAME}</key>
<source></source>
<allocation unit="G">{VDI_SIZE}</allocation>
<capacity unit="G">{VDI_SIZE}</capacity>
<target>
<path>sheepdog:{VDI_NAME}</path>
<format type='unknown'/>
<permissions>
<mode>00</mode>
<owner>0</owner>
<group>0</group>
</permissions>
</target>
</volume>
in case of erasure we need to specify number of strips and number of
parity strips. In case of copies - number of copies. How the best
encode this in xml?
P.S. I van to create patch for libvirt to allow this, but stuck at xml
definition.
--
Vasiliy Tolstov,
e-mail: v.tolstov(a)selfip.ru
9 years, 4 months
[libvirt] [PATCHv2] virt-aa-helper: Fix permissions for vhost-user socket files
by Michal Dubiel
QEMU working in vhost-user mode communicates with the other end (i.e.
some virtual router application) via unix domain sockets. This requires
that permissions for the socket files are correctly written into
/etc/apparmor.d/libvirt/libvirt-UUID.files.
Signed-off-by: Michal Dubiel <md(a)semihalf.com>
---
Changes since v1:
- Removed unnecessary stat() call and dead 'else' block
src/security/virt-aa-helper.c | 25 ++++++++++++-------------
1 file changed, 12 insertions(+), 13 deletions(-)
diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c
index 35423b5..f39932e 100644
--- a/src/security/virt-aa-helper.c
+++ b/src/security/virt-aa-helper.c
@@ -32,7 +32,6 @@
#include <unistd.h>
#include <errno.h>
#include <sys/types.h>
-#include <sys/stat.h>
#include <fcntl.h>
#include <getopt.h>
#include <sys/utsname.h>
@@ -542,7 +541,6 @@ array_starts_with(const char *str, const char * const *arr, const long size)
static int
valid_path(const char *path, const bool readonly)
{
- struct stat sb;
int npaths, opaths;
const char * const restricted[] = {
"/bin/",
@@ -592,17 +590,6 @@ valid_path(const char *path, const bool readonly)
if (!virFileExists(path)) {
vah_warning(_("path does not exist, skipping file type checks"));
- } else {
- if (stat(path, &sb) == -1)
- return -1;
-
- switch (sb.st_mode & S_IFMT) {
- case S_IFSOCK:
- return 1;
- break;
- default:
- break;
- }
}
opaths = sizeof(override)/sizeof(*(override));
@@ -1101,6 +1088,18 @@ get_files(vahControl * ctl)
}
}
+ for (i = 0; i < ctl->def->nnets; i++) {
+ if (ctl->def->nets[i] &&
+ ctl->def->nets[i]->type == VIR_DOMAIN_NET_TYPE_VHOSTUSER &&
+ ctl->def->nets[i]->data.vhostuser) {
+ virDomainChrSourceDefPtr vhu = ctl->def->nets[i]->data.vhostuser;
+
+ if (vah_add_file_chardev(&buf, vhu->data.nix.path, "rw",
+ vhu->type) != 0)
+ goto cleanup;
+ }
+ }
+
if (ctl->def->virtType == VIR_DOMAIN_VIRT_KVM) {
for (i = 0; i < ctl->def->nnets; i++) {
virDomainNetDefPtr net = ctl->def->nets[i];
--
1.9.1
9 years, 4 months
[libvirt] [PATCH sandbox] Ensure libvirt-sandbox-init-common uses correct ld-linux
by Daniel P. Berrange
The libc.so library requires certainly functionality to be
provided by the ld-linux.so library. The ld-linux.so is loaded
by the kernel based on the PT_INTERP ELF section, and as such
LD_LIBRARY_PATH has no effect.
So, although libvirt-sandbox-init-{qemu,lxc} set LD_LIBRARY_PATH
to force use of the libs from the host OS image, the common
init program was stil using the ld-linux.so from the guest OS
image. Sometimes this works, sometimes it breaks.
When trying to run Fedora 19 as the root filesystem from a
Fedora 22 host, it would break thus:
/etc/libvirt-sandbox/scratch/.libs/libvirt-sandbox-init-common: relocation error: /etc/libvirt-sandbox/scratch/.libs/libc.so.6: symbol _dl_find_dso_for_object, version GLIBC_PRIVATE not defined in file ld-linux-x86-64.so.2 with link time reference
To deal with this we must ensure that we always invoke the
libvirt-sandbox-init-common program using the ld-linux that
was provided by the host OS image.
The sandbox builder is tweaked so that it always copies the
host ld-linux.so into the libs scratch directory, and gives
it a predictable name 'ld.so', since every architecture seems
to have a different name.
The libvirt-sandbox-init-{lxc,qemu} files are changed so that
instead of exec'ing libvirt-sandbox-init-common directly, they
will load it via the ld.so file.
---
libvirt-sandbox/libvirt-sandbox-builder.c | 28 +++++++++++++++++++++++-----
libvirt-sandbox/libvirt-sandbox-init-lxc.c | 1 +
libvirt-sandbox/libvirt-sandbox-init-qemu.c | 1 +
3 files changed, 25 insertions(+), 5 deletions(-)
diff --git a/libvirt-sandbox/libvirt-sandbox-builder.c b/libvirt-sandbox/libvirt-sandbox-builder.c
index 2726868..e615606 100644
--- a/libvirt-sandbox/libvirt-sandbox-builder.c
+++ b/libvirt-sandbox/libvirt-sandbox-builder.c
@@ -252,10 +252,11 @@ GVirConnection *gvir_sandbox_builder_get_connection(GVirSandboxBuilder *builder)
static gboolean gvir_sandbox_builder_copy_file(const char *path,
const char *libsdir,
+ const char *newname,
GError **error)
{
gchar *name = g_path_get_basename(path);
- gchar *target = g_build_filename(libsdir, name, NULL);
+ gchar *target = g_build_filename(libsdir, newname ? newname : name, NULL);
GFile *srcFile = g_file_new_for_path(path);
GFile *tgtFile = g_file_new_for_path(target);
gboolean result = FALSE;
@@ -285,7 +286,7 @@ static gboolean gvir_sandbox_builder_copy_program(const char *program,
const gchar *argv[] = {LDD_PATH, program, NULL};
gboolean result = FALSE;
- if (!gvir_sandbox_builder_copy_file(program, dest, error))
+ if (!gvir_sandbox_builder_copy_file(program, dest, NULL, error))
goto cleanup;
@@ -301,14 +302,31 @@ static gboolean gvir_sandbox_builder_copy_program(const char *program,
*tmp = '\0';
/* Search the line for the library path */
- start = strstr(line, " => ");
+ start = strstr(line, "/");
end = strstr(line, " (");
if (start && end) {
- start = start + 4;
+ const gchar *newname = NULL;
*end = '\0';
- if (!gvir_sandbox_builder_copy_file(start, dest, error))
+ /* There are countless different naming schemes for
+ * the ld-linux.so library across architectures. Pretty
+ * much the only thing in common is they start with
+ * the two letters 'ld'. The LDD program prints it
+ * out differently too - it doesn't include " => "
+ * as this library is special - its actually a static
+ * linked executable not a library.
+ *
+ * To make life easier for libvirt-sandbox-init-{qemu,lxc}
+ * we just call the file 'ld.so' when we copy it into our
+ * scratch dir, no matter what it was called on the host.
+ */
+ if (!strstr(line, " => ") &&
+ strstr(start, "/ld")) {
+ newname = "ld.so";
+ }
+
+ if (!gvir_sandbox_builder_copy_file(start, dest, newname, error))
goto cleanup;
}
diff --git a/libvirt-sandbox/libvirt-sandbox-init-lxc.c b/libvirt-sandbox/libvirt-sandbox-init-lxc.c
index e2fe7f0..d1e4a79 100644
--- a/libvirt-sandbox/libvirt-sandbox-init-lxc.c
+++ b/libvirt-sandbox/libvirt-sandbox-init-lxc.c
@@ -77,6 +77,7 @@ main(int argc, char **argv)
args[narg++] = "1000";
}
+ args[narg++] = SANDBOXCONFIGDIR "/.libs/ld.so";
args[narg++] = SANDBOXCONFIGDIR "/.libs/libvirt-sandbox-init-common";
if (debug)
args[narg++] = "-d";
diff --git a/libvirt-sandbox/libvirt-sandbox-init-qemu.c b/libvirt-sandbox/libvirt-sandbox-init-qemu.c
index 09580da..cd6055a 100644
--- a/libvirt-sandbox/libvirt-sandbox-init-qemu.c
+++ b/libvirt-sandbox/libvirt-sandbox-init-qemu.c
@@ -422,6 +422,7 @@ main(int argc ATTR_UNUSED, char **argv ATTR_UNUSED)
args[narg++] = "1000";
}
+ args[narg++] = SANDBOXCONFIGDIR "/.libs/ld.so";
args[narg++] = SANDBOXCONFIGDIR "/.libs/libvirt-sandbox-init-common";
if (debug)
args[narg++] = "-d";
--
2.4.3
9 years, 4 months
[libvirt] [PATCH] qemu: Avoid using ".(null)" in UNIX socket path
by Jiri Denemark
The code which generates paths for UNIX socket blindly used target name
without checking if it was set. Thus for the following device XML
<channel type='unix'>
<source mode='bind'/>
<target type='virtio'/>
</channel>
we would generate "/var/lib/libvirt/qemu/channel/target/NAME.(null)"
path which works but is not really correct. Let's not use the
".target_name" suffix at all if target name is not set.
https://bugzilla.redhat.com/show_bug.cgi?id=1226854
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
src/qemu/qemu_domain.c | 20 +++++++++---
.../qemuxml2argv-channel-virtio-unix.args | 19 +++++++++++
.../qemuxml2argv-channel-virtio-unix.xml | 37 ++++++++++++++++++++++
tests/qemuxml2argvtest.c | 5 +++
4 files changed, 77 insertions(+), 4 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-channel-virtio-unix.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-channel-virtio-unix.xml
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 6213fd9..404489c 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -1249,11 +1249,23 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
dev->data.chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL &&
dev->data.chr->targetType == VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO &&
dev->data.chr->source.type == VIR_DOMAIN_CHR_TYPE_UNIX &&
- !dev->data.chr->source.data.nix.path && cfg) {
- if (virAsprintf(&dev->data.chr->source.data.nix.path, "%s/%s.%s",
- cfg->channelTargetDir,
- def->name, dev->data.chr->target.name) < 0)
+ !dev->data.chr->source.data.nix.path) {
+ if (!cfg) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("cannot generate UNIX socket path"));
goto cleanup;
+ }
+
+ if (dev->data.chr->target.name) {
+ if (virAsprintf(&dev->data.chr->source.data.nix.path, "%s/%s.%s",
+ cfg->channelTargetDir,
+ def->name, dev->data.chr->target.name) < 0)
+ goto cleanup;
+ } else {
+ if (virAsprintf(&dev->data.chr->source.data.nix.path, "%s/%s",
+ cfg->channelTargetDir, def->name) < 0)
+ goto cleanup;
+ }
dev->data.chr->source.data.nix.listen = true;
}
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-channel-virtio-unix.args b/tests/qemuxml2argvdata/qemuxml2argv-channel-virtio-unix.args
new file mode 100644
index 0000000..43a34ce
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-channel-virtio-unix.args
@@ -0,0 +1,19 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
+/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 \
+-device virtio-serial-pci,id=virtio-serial1,bus=pci.0,addr=0xa \
+-device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x3 \
+-usb \
+-hda /dev/HostVG/QEMUGuest1 \
+-chardev socket,id=charchannel0,path=\
+/tmp/QEMUGuest1.org.qemu.guest_agent.0,server,nowait \
+-device virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,id=channel0,\
+name=org.qemu.guest_agent.0 \
+-chardev socket,id=charchannel1,path=/tmp/QEMUGuest1,server,nowait \
+-device virtserialport,bus=virtio-serial0.0,nr=2,chardev=charchannel1,id=channel1 \
+-chardev socket,id=charchannel2,path=/tmp/QEMUGuest1.ble,server,nowait \
+-device virtserialport,bus=virtio-serial0.0,nr=3,chardev=charchannel2,id=channel2,\
+name=ble
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-channel-virtio-unix.xml b/tests/qemuxml2argvdata/qemuxml2argv-channel-virtio-unix.xml
new file mode 100644
index 0000000..7fac943
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-channel-virtio-unix.xml
@@ -0,0 +1,37 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219136</memory>
+ <vcpu placement='static' 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' target='0' unit='0'/>
+ </disk>
+ <controller type='usb' index='0'/>
+ <controller type='ide' index='0'/>
+ <controller type='virtio-serial' index='1'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
+ </controller>
+ <channel type='unix'>
+ <target type='virtio' name='org.qemu.guest_agent.0'/>
+ </channel>
+ <channel type='unix'>
+ <target type='virtio'/>
+ </channel>
+ <channel type='unix'>
+ <target type='virtio' name='ble'/>
+ </channel>
+ <memballoon model='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 4154601..6f8332d 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -519,6 +519,9 @@ mymain(void)
driver.config->spiceTLS = 1;
if (VIR_STRDUP_QUIET(driver.config->spicePassword, "123456") < 0)
return EXIT_FAILURE;
+ VIR_FREE(driver.config->channelTargetDir);
+ if (VIR_STRDUP_QUIET(driver.config->channelTargetDir, "/tmp") < 0)
+ return EXIT_FAILURE;
# define DO_TEST_FULL(name, migrateFrom, migrateFd, flags, ...) \
do { \
@@ -1113,6 +1116,8 @@ mymain(void)
DO_TEST("channel-virtio-default",
QEMU_CAPS_DEVICE, QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG,
QEMU_CAPS_SPICE, QEMU_CAPS_CHARDEV_SPICEVMC);
+ DO_TEST("channel-virtio-unix",
+ QEMU_CAPS_DEVICE, QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG);
DO_TEST("smartcard-host",
QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE,
--
2.4.5
9 years, 4 months
[libvirt] [PATCH] qemu: agent: Don't automatically disable CPU0 via guest agent
by Peter Krempa
While CPU0 was made unpluggable in Linux a while ago it's not desirable
to unplug it since some parts of the kernel (suspend-to-ram) still
depend on it.
This patch fixes the vCPU selection code in libvirt so that it will not
be disabled.
---
src/qemu/qemu_agent.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
index 043695b..7021a7a 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -1601,9 +1601,13 @@ qemuAgentUpdateCPUInfo(unsigned int nvcpus,
size_t i;
int nonline = 0;
int nofflinable = 0;
+ ssize_t cpu0 = -1;
/* count the active and offlinable cpus */
for (i = 0; i < ncpuinfo; i++) {
+ if (cpuinfo[i].id == 0)
+ cpu0 = i;
+
if (cpuinfo[i].online)
nonline++;
@@ -1618,6 +1622,15 @@ qemuAgentUpdateCPUInfo(unsigned int nvcpus,
}
}
+ /* CPU0 was made offlinable in linux a while ago, but certain parts (suspend
+ * to ram) of the kernel still don't cope well with that. Make sure that if
+ * all remaining vCPUs are offlinable, vCPU0 will not be selected to be
+ * offlined automatically */
+ if (nofflinable == nonline && cpu0 >= 0 && cpuinfo[cpu0].online) {
+ cpuinfo[cpu0].offlinable = false;
+ nofflinable--;
+ }
+
/* the guest agent reported less cpus than requested */
if (nvcpus > ncpuinfo) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
--
2.4.1
9 years, 4 months