[libvirt] [PATCH 0/2] VirtFS fixes needed for supporting fs driver in VMM
by Deepak C Shetty
These are the libvirt changes needed to ensure that the
virt-manager changes done for supporting fs driver work well.
---
Deepak C Shetty (2):
Set default fs driver when not provided in input xml
Do not generate security_model when fs driver is anything but 'path'
src/conf/domain_conf.c | 15 +++++++++++----
src/qemu/qemu_command.c | 15 +++++++++------
2 files changed, 20 insertions(+), 10 deletions(-)
--
Signature
12 years, 10 months
[libvirt] [libvirt-glib 1/2] API to suspend a domain
by Zeeshan Ali (Khattak)
From: "Zeeshan Ali (Khattak)" <zeeshanak(a)gnome.org>
---
libvirt-gobject/libvirt-gobject-domain.c | 30 ++++++++++++++++++++++++++++++
libvirt-gobject/libvirt-gobject-domain.h | 3 +++
libvirt-gobject/libvirt-gobject.sym | 1 +
3 files changed, 34 insertions(+), 0 deletions(-)
diff --git a/libvirt-gobject/libvirt-gobject-domain.c b/libvirt-gobject/libvirt-gobject-domain.c
index 4301b14..e4963ed 100644
--- a/libvirt-gobject/libvirt-gobject-domain.c
+++ b/libvirt-gobject/libvirt-gobject-domain.c
@@ -678,3 +678,33 @@ gboolean gvir_domain_open_graphics(GVirDomain *dom,
cleanup:
return ret;
}
+
+/**
+ * gir_domain_suspend:
+ * @dom: the domain to suspend
+ * @err: Place-holder for possible errors
+ *
+ * Suspends an active domain, the process is frozen without further access to
+ * CPU resources and I/O but the memory used by the domain at the hypervisor
+ * level will stay allocated. Use gvir_domain_resume() to reactivate the domain.
+ *
+ * Returns: TRUE if domain was suspended successfully, FALSE otherwise.
+ */
+gboolean gvir_domain_suspend (GVirDomain *dom,
+ GError **err)
+{
+ gboolean ret = FALSE;
+
+ g_return_val_if_fail(GVIR_IS_DOMAIN(dom), FALSE);
+
+ if (virDomainSuspend(dom->priv->handle) < 0) {
+ gvir_set_error_literal(err, GVIR_DOMAIN_ERROR,
+ 0,
+ "Unable to suspend domain");
+ goto cleanup;
+ }
+
+ ret = TRUE;
+cleanup:
+ return ret;
+}
diff --git a/libvirt-gobject/libvirt-gobject-domain.h b/libvirt-gobject/libvirt-gobject-domain.h
index 6fcec8d..a5923f4 100644
--- a/libvirt-gobject/libvirt-gobject-domain.h
+++ b/libvirt-gobject/libvirt-gobject-domain.h
@@ -153,6 +153,9 @@ gboolean gvir_domain_open_graphics(GVirDomain *dom,
unsigned int flags,
GError **err);
+gboolean gvir_domain_suspend (GVirDomain *dom,
+ GError **err);
+
G_END_DECLS
#endif /* __LIBVIRT_GOBJECT_DOMAIN_H__ */
diff --git a/libvirt-gobject/libvirt-gobject.sym b/libvirt-gobject/libvirt-gobject.sym
index a523adc..526098d 100644
--- a/libvirt-gobject/libvirt-gobject.sym
+++ b/libvirt-gobject/libvirt-gobject.sym
@@ -51,6 +51,7 @@ LIBVIRT_GOBJECT_0.0.3 {
gvir_domain_start;
gvir_domain_resume;
gvir_domain_stop;
+ gvir_domain_suspend;
gvir_domain_delete;
gvir_domain_open_console;
gvir_domain_open_graphics;
--
1.7.7.4
12 years, 10 months
[libvirt] [PATCH v2 0/5] RFC: grant KVM guests retain arbitrary capabilities
by Taku Izumi
Hi Daniel-san and all,
This patchset adds an option for KVM guests to retain arbitrary capabilities.
The first version is here:
http://www.redhat.com/archives/libvir-list/2011-December/msg00857.html
According to Daniel-san's comment, I changed my patch like the following:
v1 -> v2
- introduce "process" and "cap" elements in the capability XML
- change XML element name of domain XML likewise
; process capabilities host supports are found in the capability XML.
# virsh capabilities
<capabilities>
<host>
<uuid>00000000-0000-0000-0000-00199914f1c5</uuid>
...
<process>
<cap name='chown'/>
<cap name='dac_override'/>
<cap name='dac_read_search'/>
<cap name='fowner'/>
...
</process>
</host>
...
; VM can retain cap_sys_rawio capability
# virsh edit VM
...
</features>
<process>
<cap name='sys_rawio'/>
</process>
<clock offset='utc'/>
...
# virsh start VM
# cat /proc/<VM's PID>/status
...
CapInh: 0000000000000000
CapPrm: fffffffc00020000
CapEff: fffffffc00020000
CapBnd: fffffffc00020000
...
*[PATCH v2 1/5] conf: add XML schema for capability XML
*[PATCH v2 2/5] conf: add XML schema for domain XML
*[PATCH v2 3/5] util: add functions to keep capabilities
*[PATCH v2 4/5] util: extend virExecWithHook()
*[PATCH v2 5/5] qemu: make qemu processes to retain capabilities
Best regards,
Taku Izumi
12 years, 10 months
[libvirt] [PATCHv2] python: Fix problems of virDomain{Set, Get}BlkioParameters bindings
by ajia@redhat.com
From: Alex Jia <ajia(a)redhat.com>
The parameter 'device_weight' is a string, however, the 'VIR_TYPED_PARAM_STRING'
type condition is missed by libvirt_virDomain{Set, Get}BlkioParameters bindings,
the result is we can't get or change 'device_weight' value.
* python/libvirt-override.c: Add missing 'VIR_TYPED_PARAM_STRING' condition into
libvirt_virDomain{Set, Get}BlkioParameters bindings and free allocated memory.
https://bugzilla.redhat.com/show_bug.cgi?id=770795
Signed-off-by: Alex Jia <ajia(a)redhat.com>
---
python/libvirt-override.c | 20 ++++++++++++++++++++
1 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/python/libvirt-override.c b/python/libvirt-override.c
index d2aad0f..38a35b8 100644
--- a/python/libvirt-override.c
+++ b/python/libvirt-override.c
@@ -726,6 +726,10 @@ libvirt_virDomainSetBlkioParameters(PyObject *self ATTRIBUTE_UNUSED,
}
break;
+ case VIR_TYPED_PARAM_STRING:
+ params[i].value.s = PyString_AsString(val);
+ break;
+
default:
free(params);
return VIR_PY_INT_FAIL;
@@ -735,6 +739,11 @@ libvirt_virDomainSetBlkioParameters(PyObject *self ATTRIBUTE_UNUSED,
LIBVIRT_BEGIN_ALLOW_THREADS;
i_retval = virDomainSetBlkioParameters(domain, params, nparams, flags);
LIBVIRT_END_ALLOW_THREADS;
+
+ for(i=0; i < nparams; i++)
+ if (params[i].type == VIR_TYPED_PARAM_STRING)
+ free(params[i].value.s);
+
if (i_retval < 0) {
free(params);
return VIR_PY_INT_FAIL;
@@ -811,6 +820,10 @@ libvirt_virDomainGetBlkioParameters(PyObject *self ATTRIBUTE_UNUSED,
val = PyBool_FromLong((long)params[i].value.b);
break;
+ case VIR_TYPED_PARAM_STRING:
+ val = PyString_FromString((char *)params[i].value.s);
+ break;
+
default:
free(params);
Py_DECREF(info);
@@ -819,7 +832,14 @@ libvirt_virDomainGetBlkioParameters(PyObject *self ATTRIBUTE_UNUSED,
key = libvirt_constcharPtrWrap(params[i].field);
PyDict_SetItem(info, key, val);
+ Py_DECREF(key);
+ Py_DECREF(val);
}
+
+ for(i=0; i < nparams; i++)
+ if (params[i].type == VIR_TYPED_PARAM_STRING)
+ free(params[i].value.s);
+
free(params);
return(info);
}
--
1.7.1
12 years, 10 months
Re: [libvirt] [libvirt-glib] Correct namespace prefix for GVirConfig symbols
by Zeeshan Ali (Khattak)
On Thu, Dec 22, 2011 at 1:43 AM, Zeeshan Ali (Khattak)
<zeeshanak(a)gnome.org> wrote:
> From: "Zeeshan Ali (Khattak)" <zeeshanak(a)gnome.org>
>
> Breaks API and ABI on the fundamental level but lets fix this now while
> we don't guarantee any API/ABI stability.
Forgot to mention that this patch is on top of Christophe's ACK'ed but
unmerged 'Add GVirConfigDomainSound' tree.
--
Regards,
Zeeshan Ali (Khattak)
FSF member#5124
12 years, 10 months
[libvirt] [PATCH][TCK] add test case for block job lifecycle testing
by xhu
diff --git a/scripts/domain/400-blockjob-lifecycle.t b/scripts/domain/400-blockjob-lifecycle.t
new file mode 100644
index 0000000..f4d0c39
--- /dev/null
+++ b/scripts/domain/400-blockjob-lifecycle.t
@@ -0,0 +1,136 @@
+# -*- perl -*-
+#
+# Copyright (C) 2011-2012 Red Hat, Inc.
+# Copyright (C) 2011 Xiaoqiang Hu <xhu(a)redhat.com>
+#
+# This program is free software; You can redistribute it and/or modify
+# it under the GNU General Public License as published by the Free
+# Software Foundation; either version 2, or (at your option) any
+# later version
+#
+# The file "LICENSE" distributed along with this file provides full
+# details of the terms and conditions
+#
+
+=pod
+
+=head1 NAME
+
+domain/400-block-pull-abort-info.t - verify the lifecycle of block job:
+block pull, set block job speed, get block job info and abort block job
+
+=head1 DESCRIPTION
+
+The test case validates that it is fine to block pull, set block job speed
+, get block job info and abort block job for domain using qed img with
+qed backing img
+
+=cut
+
+use strict;
+use warnings;
+
+use Test::More tests => 16;
+
+use Sys::Virt::TCK;
+use Test::Exception;
+use File::Spec::Functions qw(catfile);
+use File::stat;
+
+my $tck = Sys::Virt::TCK->new();
+my $conn = eval { $tck->setup(); };
+BAIL_OUT "failed to setup test harness: $@" if $@;
+END {
+ $tck->cleanup if $tck;
+}
+
+my $xml = $tck->generic_pool("dir")
+ ->mode("0755")->as_xml;
+
+diag "Defining transient storage pool $xml";
+my $pool;
+
+ok_pool(sub { $pool = $conn->define_storage_pool($xml) }, "define transient storage pool");
+lives_ok(sub { $pool->build(0) }, "built storage pool");
+lives_ok(sub { $pool->create }, "started storage pool");
+
+my $volbackxml = $tck->generic_volume("tck-back", "qed", 1024*1024*50)->allocation(0)->as_xml;
+
+my ($volback, $pathback);
+diag "back $volbackxml";
+ok_volume(sub { $volback = $pool->create_volume($volbackxml) }, "create raw backing file volume");
+
+my $st;
+$pathback = xpath($volback, "string(/volume/target/path)");
+$st = stat($pathback);
+
+ok($st, "path $pathback exists");
+
+ok($st->size < 1024*1024, "size is < 1M");
+
+my $volmainxml = $tck->generic_volume("tck-main", "qed", 1024*1024*50)
+ ->backing_file($pathback)
+ ->backing_format("qed")
+ ->allocation(0)->as_xml;
+
+my ($volmain, $pathmain);
+diag "main $volmainxml";
+ok_volume(sub { $volmain = $pool->create_volume($volmainxml) }, "create qed backing file volume");
+
+$pathmain = xpath($volmain, "string(/volume/target/path)");
+$st = stat($pathmain);
+
+ok($st, "path $pathmain exists");
+
+ok($st->size < 1024*1024, "size is < 1M");
+
+# define the guest at a qed image
+# and the backing store in this qed image.
+$xml = $tck->generic_domain("tck")
+ ->disk(format => { name => "qemu", type => "qed" },
+ type => "file",
+ src => $pathmain,
+ dst => "vdb")
+ ->as_xml;
+
+diag "Defining an inactive domain config $xml";
+my $dom;
+ok_domain(sub { $dom = $conn->define_domain($xml) }, "defined persistent domain config");
+
+diag "Starting inactive domain config";
+$dom->create;
+ok($dom->get_id() > 0, "running domain has an ID > 0");
+
+# start to block pull and bandwidth is 1MB/S
+my ($bandwidth, $flags, $jobinfo);
+# 1024 KB/S - 1MB/S
+$bandwidth = 1*1024;
+$flags=0;
+$dom->block_pull($pathmain, $bandwidth, $flags);
+# $jobinfo is a hash reference summarising the execution state of the block job.
+# and it has four keys:cur, end, bandwidth, type
+$jobinfo = $dom->get_block_job_info($pathmain, $flags);
+ok($jobinfo->{bandwidth} == $bandwidth, "start to block pull and block job bandwidth is $bandwidth");
+
+$dom->abort_block_job($pathmain, $flags);
+$jobinfo = $dom->get_block_job_info($pathmain, $flags);
+ok($jobinfo->{type} == 0, "abort block job");
+
+$dom->block_pull($pathmain, $bandwidth, $flags);
+$jobinfo = $dom->get_block_job_info($pathmain, $flags);
+ok($jobinfo->{bandwidth} == $bandwidth, "continue to block pull and block job bandwidth is $bandwidth");
+
+# set block job bandwidth to 2MB/S
+$bandwidth = 2*1024;
+$dom->set_block_job_speed($pathmain, $bandwidth, $flags);
+$jobinfo = $dom->get_block_job_info($pathmain, $flags);
+ok($jobinfo->{bandwidth} == $bandwidth, "block job bandwidth is set to $bandwidth");
+
+# wait for the end of block pull
+while($jobinfo->{cur} < $jobinfo->{end} && $jobinfo->{type} == 1) {
+ $jobinfo = $dom->get_block_job_info($pathmain, $flags);
+ sleep 1
+}
+
+ok($jobinfo->{type} == 0, "block pull is finished");
+# end
--
1.7.1
12 years, 10 months
[libvirt] Libvirt java from Windows
by Sergey Sudakovich (ssudakov)
I am writing a java based client that would be executed from windows
that will use libvirt.
1. Got libvirt-java (
http://libvirt.org/sources/java/libvirt-java-0.4.7.tar.gz) and build a
jar out it (ant with no params)
2. Then, according to http://libvirt.org/windows.html, built a dll
using the "MSYS build script"
3. Got 2 files libvirt-0.dll and libqemu-0.dll
When I run the sample example(from Eclipse) from
http://libvirt.org/java.html I get the following error:
Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to
load library 'virt': %1 is not a valid Win32 application.
at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:169)
at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:242)
at com.sun.jna.Library$Handler.<init>(Library.java:140)
at com.sun.jna.Native.loadLibrary(Native.java:368)
at com.sun.jna.Native.loadLibrary(Native.java:353)
at org.libvirt.jna.Libvirt.<clinit>(Unknown Source)
at org.libvirt.Connect.<clinit>(Unknown Source)
at Main.main(Main.java:26)
Also tried instead of step 2 cross compile in Fedora - same error
message when I use new dll's.
Does anybody have any idea where do I start fixing the issue??
--
Thank you,
Sergey Sudakovich
12 years, 10 months
[libvirt] virtio-scsi support proposal, v2
by Paolo Bonzini
Here is a revised version of the virtio-scsi proposal. There's actually
not too much left intact from v1. :)
The main simplification is in how SCSI hosts can be addressed in a stable
manner.
SCSI controller models
======================
Existing controller models are "auto", "buslogic", "lsilogic", "lsias1068",
or "vmpvscsi". The new controller model "virtio-scsi" is added. The model
"lsilogic" is mapped to the existing "lsi" device in QEMU.
When PPC64 support will be added, another controller model "spapr-vscsi"
will be added.
Stable addressing for SCSI devices
==================================
The existing <address type='drive' ...> element will be extended as follows:
<address type='drive' controller='...'
bus='...' target='...' unit='...'/>
where controller selects the qdev parent device, while bus/target/unit
are passed as qdev properties (the QEMU names are respectively channel,
scsi-id, lun).
Libvirt should check for the QEMU "scsi-disk.channel" property. If it
is unavailable, QEMU will only support channel=lun=0 and 0<=target<=7.
LUN passthrough: block devices
==============================
A SCSI block device from the host can be attached to a domain in two
ways: as an emulated LUN with SCSI commands implemented within QEMU,
or by passing SCSI commands down to the block device. The former is
handled by the existing <disk type='file'>, <disk type='block'> and
<disk type='network'> XML syntax. The latter is not yet supported.
On the QEMU side, LUN passthrough is implemented by one of the
scsi-generic and scsi-block devices. Scsi-generic requires a /dev/sg
device name, and can be applied to any device. scsi-block is only
available in QEMU 1.0 or newer, requires a block device, can be applied
only to block devices (sd/sr) and has better performance.
To implement LUN passthrough for block device, libvirt will add a new
<disk device='lun'> attribute. When, device='lun' is passed, the device
attribute is ignored.
Example:
<disk type='block' device='lun'>
<disk name='qemu' type='raw'/>
<source dev='/dev/sda'/>
<target dev='sda' bus='scsi'>
<address type='drive' controller='...'
bus='...' target='...' unit='...'/>
</disk>
Also, virtio-blk handling will be enhanced to disable SG_IO passthrough
when <disk device='disk'>, and only enable it when <disk device='lun'>.
(I am not sure whether the 'lun' value should be for the type or device
attribute. Laine has a patch to implement it for virtio disks which
uses "type").
This syntax makes it clear what is the passed-through device, and at
the same time it makes it very easy to switch a disk between emulated
and passthrough modes. Also, a stable addressing for the source device
is provided by /dev/disk/by-id and /dev/disk/by-path.
Stable SCSI host addressing
===========================
SCSI host number in Linux is not stable. An alternative stable
addressing is required to pass a whole host or target to a guest.
One place in which this could be supported is the SCSI volume pool
syntax:
<pool type='scsi'>
<name>virtimages</name>
<source>
<adapter name='host0'/>
</source>
<target>
<path>/dev/disk/by-id</path>
</target>
</pool>
libvirt will deprecate the above form for the adapter element and
provide the following forms:
<adapter name='scsi_host0'/>
<adapter parent='pci_0000_00_1f_2' unique_id='1'/>
The existing form changes from host0 to scsi_host0, for
consistency with the naming that is used in nodedev. The new
parent/unique_id addressing uses a parent PCI device and a unique
id that Linux provides in sysfs. In order to determine the SCSI
host number, libvirt would scan all files matched by the glob pattern
/sys/bus/pci/devices/0000:00:1f.2/*/scsi_host/*/unique_id, looking for
the one that contains "1".
The unique_id can be omitted. In this case, the pool will refer
to the host with the smallest unique_id under the given device.
Furthermore, a SCSI pool can be restricted to one target using an
additional element:
<source>
<adapter name='scsi_host0'/>
<address type='scsi' bus='0' target='0'/>
</source>
(bus defaults to 0, target is mandatory).
Generic passthrough
===================
Generic device passthrough at the LUN, target or host level builds
on the extensions to SCSI addressing from the previous section.
Passing a single LUN extends the <hostdev> tag as follows:
<hostdev type='scsi'>
<source>
<adapter name='scsi_host0'/>
<address type='scsi' bus='0' target='0' unit='0'/>
</source>
<target>
<address type='scsi' controller='...'
bus='...' target='...' unit='...'/>
</target>
</hostdev>
This will map to a -drive QEMU option referring to a scsi-generic
device, and a "-device scsi-generic" option referring to the drive.
libvirt can determine the /dev/sg file to use by reading the directory
/sys/bus/scsi/devices/target*/*/scsi_generic. These devices might also
be shown in the nodedev tree, similar to block devices.
Whenever a domain should receive all devices belonging to a SCSI host,
a similar <source> item should be included within the <controller
type='scsi'> element:
<controller type='scsi' model='virtio-scsi'>
<source>
<adapter name='scsi_host0'/>
</source>
</controller>
In this case, libvirt should use scsi-block rather than scsi-generic
for block devices.
NPIV-based SCSI host passthrough
================================
In NPIV, a virtual HBA is created using "virsh nodedev-create" and passed
to the guest. Passing through a whole SCSI host is quite common when
using NPIV. As a result, it is desirable to easily address virtual HBAs
both in SCSI storage pools and in <controller type='scsi'> elements.
Here are two proposals for how to refer to NPIV adapters:
1) add persistent nodedevs via commands nodedev-define, nodedev-undefine,
nodedev-start. The persistent nodedevs have a name, and this can be
used simply with <adapter name='NAME'>.
2) Virtual adapters do have a stable address, namely its WWN. This
can be used in a third <adapter> syntax:
<source>
<adapter type='fc_host' wwpn='...' wwnn='...'/>
</source>
12 years, 10 months
[libvirt] [PATCH 0/3] python: Fix memory leaks
by ajia@redhat.com
From: Alex Jia <ajia(a)redhat.com>
This series patches fix memory leaks issues. Detected by valgrind.
Alex Jia (3):
* python/libvirt-override.c: fix memory leaks on libvirt_virDomainBlockStatsFlags.
* python/libvirt-override.c: fix memory leaks on libvirt_virDomainGetSchedulerParameters
and libvirt_virDomainGetSchedulerParametersFlags.
* python/libvirt-override.c: fix memory leaks on libvirt_virDomainGetMemoryParameters.
Signed-off-by: Alex Jia <ajia(a)redhat.com>
12 years, 10 months