[libvirt] [PATCH v2] Add new attribute writeout to <filesystem> element
by Deepak C Shetty
This introduces new attribute writeout with only supported
value as immediate. This will be an optional
attribute with no defaults. This helps specify whether
to skip the host page cache.
When writeout is specified, meaning when writeout=immediate
a writeback is explicitly initiated for the dirty pages in
the host page cache as part of the guest file write operation.
Usage:
<filesystem type='mount' accessmode='passthrough' writeout='immediate'>
<source dir='/export/to/guest'/>
<target dir='mount_tag'/>
</filesystem>
Currently this only works with type='mount' for the QEMU/KVM driver.
Signed-off-by: Deepak C Shetty <deepakcs(a)linux.vnet.ibm.com>
---
v2:
- added writeout as a qemu cap
- cosmetic changes in comments
- moved to using VIR_ERR_CONFIG_UNSUPPORTED
- corrected doc
docs/formatdomain.html.in | 9 ++++++++-
docs/schemas/domaincommon.rng | 5 +++++
src/conf/domain_conf.c | 29 +++++++++++++++++++++++++++--
src/conf/domain_conf.h | 10 ++++++++++
src/qemu/qemu_capabilities.c | 3 +++
src/qemu/qemu_capabilities.h | 5 +++--
src/qemu/qemu_command.c | 14 ++++++++++++++
7 files changed, 70 insertions(+), 5 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 9cf0f12..93f754a 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -1303,7 +1303,7 @@
<source name='my-vm-template'/>
<target dir='/'/>
</filesystem>
- <filesystem type='mount' accessmode='passthrough'>
+ <filesystem type='mount' accessmode='passthrough' writeout='immediate'>
<driver type='path'/>
<source dir='/export/to/guest'/>
<target dir='/import/from/host'/>
@@ -1379,6 +1379,13 @@
</dd>
</dl>
+ The filesystem block has an optional attribute <code>writeout</code> with the only
+ supported value as <code>immediate</code>. It helps specify whether to skip the host page cache.
+ When writeout is specified, meaning when writeout=immediate a writeback is explicitly initiated
+ for the dirty pages in the host page cache as part of the guest file write operation.
+ When this attribute is not specified, there are no defaults, meaning explicit writeback won't
+ be initiated.
+
</dd>
<dt><code>source</code></dt>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 553a6f0..0b37f05 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -1106,6 +1106,11 @@
<value>squash</value>
</choice>
</attribute>
+ <attribute name="writeout">
+ <choice>
+ <value>immediate</value>
+ </choice>
+ </attribute>
</optional>
</element>
</define>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 495ed33..a548b90 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -257,6 +257,9 @@ VIR_ENUM_IMPL(virDomainFSAccessMode, VIR_DOMAIN_FS_ACCESSMODE_LAST,
"mapped",
"squash")
+VIR_ENUM_IMPL(virDomainFSWriteout, VIR_DOMAIN_FS_WRITEOUT_LAST,
+ "default",
+ "immediate")
VIR_ENUM_IMPL(virDomainNet, VIR_DOMAIN_NET_TYPE_LAST,
"user",
@@ -3297,6 +3300,7 @@ virDomainFSDefParseXML(xmlNodePtr node,
char *source = NULL;
char *target = NULL;
char *accessmode = NULL;
+ char *writeout = NULL;
if (VIR_ALLOC(def) < 0) {
virReportOOMError();
@@ -3325,6 +3329,17 @@ virDomainFSDefParseXML(xmlNodePtr node,
def->accessmode = VIR_DOMAIN_FS_ACCESSMODE_PASSTHROUGH;
}
+ writeout = virXMLPropString(node, "writeout");
+ if (writeout) {
+ if ((def->writeout = virDomainFSWriteoutTypeFromString(writeout)) < 0) {
+ virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("unknown filesystem writeout '%s'"), writeout);
+ goto error;
+ }
+ } else {
+ def->writeout = VIR_DOMAIN_FS_WRITEOUT_DEFAULT;
+ }
+
cur = node->children;
while (cur != NULL) {
if (cur->type == XML_ELEMENT_NODE) {
@@ -3387,6 +3402,7 @@ cleanup:
VIR_FREE(target);
VIR_FREE(source);
VIR_FREE(accessmode);
+ VIR_FREE(writeout);
return def;
@@ -10046,6 +10062,7 @@ virDomainFSDefFormat(virBufferPtr buf,
const char *type = virDomainFSTypeToString(def->type);
const char *accessmode = virDomainFSAccessModeTypeToString(def->accessmode);
const char *fsdriver = virDomainFSDriverTypeTypeToString(def->fsdriver);
+ const char *writeout = virDomainFSWriteoutTypeToString(def->writeout);
if (!type) {
virDomainReportError(VIR_ERR_INTERNAL_ERROR,
@@ -10062,12 +10079,20 @@ virDomainFSDefFormat(virBufferPtr buf,
if (def->fsdriver == VIR_DOMAIN_FS_DRIVER_TYPE_PATH ||
def->fsdriver == VIR_DOMAIN_FS_DRIVER_TYPE_DEFAULT) {
virBufferAsprintf(buf,
- " <filesystem type='%s' accessmode='%s'>\n",
+ " <filesystem type='%s' accessmode='%s'",
type, accessmode);
} else {
virBufferAsprintf(buf,
- " <filesystem type='%s'>\n", type);
+ " <filesystem type='%s'", type);
}
+
+ /* Don't generate anything if writeout is set to default */
+ if (def->writeout) {
+ virBufferAsprintf(buf, " writeout='%s'", writeout);
+ }
+
+ /* close the filesystem element */
+ virBufferAddLit(buf,">\n");
if (def->fsdriver) {
virBufferAsprintf(buf, " <driver type='%s'/>\n", fsdriver);
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 1f6e442..6f65b4a 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -459,12 +459,21 @@ enum virDomainFSAccessMode {
VIR_DOMAIN_FS_ACCESSMODE_LAST
};
+/* Filesystem Writeout */
+enum virDomainFSWriteout {
+ VIR_DOMAIN_FS_WRITEOUT_DEFAULT = 0,
+ VIR_DOMAIN_FS_WRITEOUT_IMMEDIATE,
+
+ VIR_DOMAIN_FS_WRITEOUT_LAST
+};
+
typedef struct _virDomainFSDef virDomainFSDef;
typedef virDomainFSDef *virDomainFSDefPtr;
struct _virDomainFSDef {
int type;
int fsdriver;
int accessmode;
+ int writeout;
char *src;
char *dst;
unsigned int readonly : 1;
@@ -1974,6 +1983,7 @@ VIR_ENUM_DECL(virDomainControllerModelUSB)
VIR_ENUM_DECL(virDomainFS)
VIR_ENUM_DECL(virDomainFSDriverType)
VIR_ENUM_DECL(virDomainFSAccessMode)
+VIR_ENUM_DECL(virDomainFSWriteout)
VIR_ENUM_DECL(virDomainNet)
VIR_ENUM_DECL(virDomainNetBackend)
VIR_ENUM_DECL(virDomainNetVirtioTxMode)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 43c7578..2af16f3 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -144,6 +144,7 @@ VIR_ENUM_IMPL(qemuCaps, QEMU_CAPS_LAST,
"ich9-ahci",
"no-acpi",
"fsdev-readonly",
+ "fsdev-writeout",
);
struct qemu_feature_flags {
@@ -1083,6 +1084,8 @@ qemuCapsComputeCmdFlags(const char *help,
qemuCapsSet(flags, QEMU_CAPS_FSDEV);
if (strstr(fsdev, "readonly"))
qemuCapsSet(flags, QEMU_CAPS_FSDEV_READONLY);
+ if (strstr(fsdev, "writeout"))
+ qemuCapsSet(flags, QEMU_CAPS_FSDEV_WRITEOUT);
}
if (strstr(help, "-smbios type"))
qemuCapsSet(flags, QEMU_CAPS_SMBIOS_TYPE);
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index c759baf..5b2f932 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -113,10 +113,11 @@ enum qemuCapsFlags {
QEMU_CAPS_NO_SHUTDOWN = 74, /* usable -no-shutdown */
QEMU_CAPS_DRIVE_CACHE_UNSAFE = 75, /* Is cache=unsafe supported? */
- QEMU_CAPS_PCI_ROMBAR = 76, /* -device rombar=0|1 */
+ QEMU_CAPS_PCI_ROMBAR = 76, /* -device rombar=0|1 */
QEMU_CAPS_ICH9_AHCI = 77, /* -device ich9-ahci */
QEMU_CAPS_NO_ACPI = 78, /* -no-acpi */
- QEMU_CAPS_FSDEV_READONLY =79, /* -fsdev readonly supported */
+ QEMU_CAPS_FSDEV_READONLY = 79, /* -fsdev readonly supported */
+ QEMU_CAPS_FSDEV_WRITEOUT = 80, /* -fsdev writeout supported */
QEMU_CAPS_LAST, /* this must always be the last item */
};
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 76f3632..adfc738 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -108,6 +108,10 @@ VIR_ENUM_IMPL(qemuDomainFSDriver, VIR_DOMAIN_FS_DRIVER_TYPE_LAST,
"local",
"handle");
+VIR_ENUM_DECL(qemuDomainFSWriteout)
+VIR_ENUM_IMPL(qemuDomainFSWriteout, VIR_DOMAIN_FS_WRITEOUT_LAST,
+ "default",
+ "immediate");
static void
uname_normalize (struct utsname *ut)
@@ -2084,6 +2088,7 @@ char *qemuBuildFSStr(virDomainFSDefPtr fs,
{
virBuffer opt = VIR_BUFFER_INITIALIZER;
const char *driver = qemuDomainFSDriverTypeToString(fs->fsdriver);
+ const char *writeout = qemuDomainFSWriteoutTypeToString(fs->writeout);
if (fs->type != VIR_DOMAIN_FS_TYPE_MOUNT) {
qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
@@ -2108,6 +2113,15 @@ char *qemuBuildFSStr(virDomainFSDefPtr fs,
virBufferAddLit(&opt, ",security_model=none");
}
}
+
+ if (fs->writeout != VIR_DOMAIN_FS_WRITEOUT_DEFAULT) {
+ if (qemuCapsGet(qemuCaps, QEMU_CAPS_FSDEV_WRITEOUT)) {
+ virBufferAsprintf(&opt, ",writeout=%s", writeout);
+ } else {
+ qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("filesystem writeout not supported"));
+ }
+ }
virBufferAsprintf(&opt, ",id=%s%s", QEMU_FSDEV_HOST_PREFIX, fs->info.alias);
virBufferAsprintf(&opt, ",path=%s", fs->src);
13 years, 3 months
[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
13 years, 3 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
13 years, 3 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
13 years, 3 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
13 years, 3 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
13 years, 3 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
13 years, 3 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
13 years, 3 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>
13 years, 3 months