[libvirt] [PATCH] remote: Fill snapshot argument in remoteDomainSnapshotListAllChildren
by Peter Krempa
The remote driver did not fill the required snapshot parent argument in
the RPC call structure that caused a client crash when trying to use
this new API.
---
src/remote/remote_driver.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index b9e2127..afd367b 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -5015,6 +5015,7 @@ remoteDomainSnapshotListAllChildren(virDomainSnapshotPtr parent,
args.need_results = !!snapshots;
args.flags = flags;
+ make_nonnull_domain_snapshot(&args.snapshot, parent);
memset(&ret, 0, sizeof(ret));
if (call (parent->domain->conn,
--
1.7.8.6
12 years, 3 months
[libvirt] [glib PATCH V3] Add bindings for virDomainSnapshotCreateXML()
by Jovanka Gulicoska
---
libvirt-gobject/libvirt-gobject-domain.c | 52 ++++++++++++++++++++++++++++++++
libvirt-gobject/libvirt-gobject-domain.h | 7 +++++
libvirt-gobject/libvirt-gobject.sym | 2 ++
3 files changed, 61 insertions(+)
diff --git a/libvirt-gobject/libvirt-gobject-domain.c b/libvirt-gobject/libvirt-gobject-domain.c
index 861f713..31aa61a 100644
--- a/libvirt-gobject/libvirt-gobject-domain.c
+++ b/libvirt-gobject/libvirt-gobject-domain.c
@@ -1273,3 +1273,55 @@ GList *gvir_domain_get_devices(GVirDomain *domain,
return g_list_reverse (ret);
}
+
+/**
+ * gvir_domain_create_snapshot:
+ * @dom: the domain
+ * @custom_conf: (allow-none): configuration of snapshot or NULL
+ * @flags: the flags
+ * @err: (allow-none):Place-holder for error or NULL
+ *
+ * Returns: (transfer full): snapshot of domain. The returned object should be
+ * unreffed when no longer needed
+ */
+GVirDomainSnapshot *
+gvir_domain_create_snapshot(GVirDomain *dom,
+ GVirConfigDomainSnapshot *custom_conf,
+ guint flags,
+ GError **err)
+{
+ GVirDomainPrivate *priv;
+ virDomainSnapshot *snapshot;
+ GVirDomainSnapshot *dom_snapshot;
+ gchar *custom_xml = NULL;
+
+ g_return_val_if_fail(GVIR_IS_DOMAIN(dom), FALSE);
+ g_return_val_if_fail(err == NULL || *err == NULL, NULL);
+
+ priv = dom->priv;
+
+ if (custom_conf != NULL)
+ custom_xml = gvir_config_object_to_xml(GVIR_CONFIG_OBJECT(custom_conf));
+
+ if (!(snapshot = virDomainSnapshotCreateXML(priv->handle,
+ custom_xml,
+ flags))) {
+ const gchar *domain_name = NULL;
+ domain_name = gvir_domain_get_name(dom);
+
+ gvir_set_error(err, GVIR_DOMAIN_ERROR,
+ 0,
+ "Unable to create snapshot of %s", domain_name);
+
+ g_free(custom_xml);
+ return NULL;
+ }
+
+ dom_snapshot = GVIR_DOMAIN_SNAPSHOT(g_object_new(GVIR_TYPE_DOMAIN_SNAPSHOT,
+ "handle",
+ snapshot,
+ NULL));
+
+ g_free(custom_xml);
+ return dom_snapshot;
+}
diff --git a/libvirt-gobject/libvirt-gobject-domain.h b/libvirt-gobject/libvirt-gobject-domain.h
index c61a2f5..d10fa8d 100644
--- a/libvirt-gobject/libvirt-gobject-domain.h
+++ b/libvirt-gobject/libvirt-gobject-domain.h
@@ -31,6 +31,7 @@ G_BEGIN_DECLS
#include <libvirt-gobject/libvirt-gobject-stream.h>
#include <libvirt/libvirt.h>
+#include <libvirt-gobject/libvirt-gobject-domain-snapshot.h>
#define GVIR_TYPE_DOMAIN (gvir_domain_get_type ())
#define GVIR_DOMAIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GVIR_TYPE_DOMAIN, GVirDomain))
@@ -247,6 +248,12 @@ gboolean gvir_domain_get_saved(GVirDomain *dom);
GList *gvir_domain_get_devices(GVirDomain *domain,
GError **err);
+GVirDomainSnapshot *
+gvir_domain_create_snapshot(GVirDomain *dom,
+ GVirConfigDomainSnapshot *custom_conf,
+ guint flags,
+ 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 8f7bcef..5d15e7a 100644
--- a/libvirt-gobject/libvirt-gobject.sym
+++ b/libvirt-gobject/libvirt-gobject.sym
@@ -183,6 +183,8 @@ LIBVIRT_GOBJECT_0.1.1 {
global:
gvir_domain_shutdown_flags_get_type;
gvir_domain_xml_flags_get_type;
+
+ gvir_domain_create_snapshot;
} LIBVIRT_GOBJECT_0.0.9;
# .... define new API here using predicted next version number ....
--
1.7.11.2
12 years, 3 months
[libvirt] [PATCH v2 0/3] Per-guest S3/S4 configuration
by Martin Kletzander
There is a way to tell qemu how (not) to advertise S3/S4 ACPI sleep
state capability to the guest OS. This series includes the capability
to set this in the XML and also covers all the handling from qemu
point of view including checking for the support, parameter parsing,
command building, checking before sending the signals through guest
agent and also tests.
--
v2:
- Modified the patch to reflect danpb's notes (according to qemu
people the setting the disable_s[34] parameter to 0/1 ensures that
the states will be enabled/disabled respectively)
Martin Kletzander (3):
Add per-guest S3/S4 state configuration
qemu: Add support for S3/S4 state configuration
tests: Add tests for qemu S3/S4 state configuration
docs/schemas/domaincommon.rng | 33 ++++++
src/conf/domain_conf.c | 44 +++++++++
src/conf/domain_conf.h | 14 +++
src/libvirt_private.syms | 2 +
src/qemu/qemu_capabilities.c | 7 ++
src/qemu/qemu_capabilities.h | 2 +
src/qemu/qemu_command.c | 103 ++++++++++++++++++++
src/qemu/qemu_driver.c | 17 +++
tests/qemuargv2xmltest.c | 3 +
.../qemuxml2argv-misc-disable-s3.args | 4 +
.../qemuxml2argv-misc-disable-s3.xml | 27 +++++
.../qemuxml2argv-misc-disable-suspends.args | 4 +
.../qemuxml2argv-misc-disable-suspends.xml | 27 +++++
.../qemuxml2argv-misc-enable-s4.args | 4 +
.../qemuxml2argv-misc-enable-s4.xml | 27 +++++
tests/qemuxml2argvtest.c | 4 +
tests/qemuxml2xmltest.c | 3 +
17 files changed, 325 insertions(+), 0 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-misc-disable-s3.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-misc-disable-s3.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-misc-disable-suspends.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-misc-disable-suspends.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-misc-enable-s4.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-misc-enable-s4.xml
--
1.7.8.6
12 years, 3 months
[libvirt] [PATCH] Added timestamps to volumes
by Hendrik Schwartke
The access, modify and change times are added to volumes and
corresponding xml representations.
---
docs/schemas/storagevol.rng | 17 +++++++++++++++++
src/conf/storage_conf.c | 9 +++++++++
src/conf/storage_conf.h | 9 +++++++++
src/storage/storage_backend.c | 4 ++++
4 files changed, 39 insertions(+)
diff --git a/docs/schemas/storagevol.rng b/docs/schemas/storagevol.rng
index 7a74331..fc7eb09 100644
--- a/docs/schemas/storagevol.rng
+++ b/docs/schemas/storagevol.rng
@@ -63,6 +63,22 @@
</optional>
</define>
+ <define name='timestamps'>
+ <optional>
+ <element name='timestamps'>
+ <element name='atime'>
+ <ref name='unsignedLong'/>
+ </element>
+ <element name='mtime'>
+ <ref name='unsignedLong'/>
+ </element>
+ <element name='ctime'>
+ <ref name='unsignedLong'/>
+ </element>
+ </element>
+ </optional>
+ </define>
+
<define name='target'>
<element name='target'>
<optional>
@@ -72,6 +88,7 @@
</optional>
<ref name='format'/>
<ref name='permissions'/>
+ <ref name='timestamps'/>
<optional>
<ref name='encryption'/>
</optional>
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index ab8df9e..a4cdac8 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -1272,6 +1272,15 @@ virStorageVolTargetDefFormat(virStorageVolOptionsPtr options,
virBufferAddLit(buf," </permissions>\n");
+ virBufferAddLit(buf," <timestamps>\n");
+ virBufferAsprintf(buf," <atime>%llu</atime>\n",
+ (unsigned long long) def->timestamps.atime);
+ virBufferAsprintf(buf," <mtime>%llu</mtime>\n",
+ (unsigned long long) def->timestamps.mtime);
+ virBufferAsprintf(buf," <ctime>%llu</ctime>\n",
+ (unsigned long long) def->timestamps.ctime);
+ virBufferAddLit(buf," </timestamps>\n");
+
if (def->encryption) {
virBufferAdjustIndent(buf, 4);
if (virStorageEncryptionFormat(buf, def->encryption) < 0)
diff --git a/src/conf/storage_conf.h b/src/conf/storage_conf.h
index 5733b57..8cd1d63 100644
--- a/src/conf/storage_conf.h
+++ b/src/conf/storage_conf.h
@@ -46,6 +46,14 @@ struct _virStoragePerms {
/* Storage volumes */
+typedef struct _virStorageTimestamps virStorageTimestamps;
+typedef virStorageTimestamps *virStorageTimestampsPtr;
+struct _virStorageTimestamps {
+ time_t atime;
+ time_t mtime;
+ time_t ctime;
+};
+
/*
* How the volume's data is stored on underlying
@@ -77,6 +85,7 @@ struct _virStorageVolTarget {
char *path;
int format;
virStoragePerms perms;
+ virStorageTimestamps timestamps;
int type; /* only used by disk backend for partition type */
/* Currently used only in virStorageVolDef.target, not in .backingstore. */
virStorageEncryptionPtr encryption;
diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
index e2e9b51..c827e3c 100644
--- a/src/storage/storage_backend.c
+++ b/src/storage/storage_backend.c
@@ -1209,6 +1209,10 @@ virStorageBackendUpdateVolTargetInfoFD(virStorageVolTargetPtr target,
target->perms.uid = sb.st_uid;
target->perms.gid = sb.st_gid;
+ target->timestamps.atime = sb.st_atime;
+ target->timestamps.mtime = sb.st_mtime;
+ target->timestamps.ctime = sb.st_ctime;
+
VIR_FREE(target->perms.label);
#if HAVE_SELINUX
--
1.7.9.5
12 years, 3 months
[libvirt] [PATCH v2] qemu: Allow to attach/detach controller device persistently
by Osier Yang
* src/conf/domain_conf.c:
- Add virDomainControllerFind to find controller device by type
and index.
- Add virDomainControllerRemove to remove the controller device
from maintained controler list.
* src/conf/domain_conf.h:
- Declare the two new helpers.
* src/libvirt_private.syms:
- Expose private symbols for the two new helpers.
* src/qemu/qemu_driver.c:
- Support attach/detach controller device persistently
* src/qemu/qemu_hotplug.c:
- Use the two helpers to simplify the codes.
v1 - v2:
- Allow to detach the controller too.
---
src/conf/domain_conf.c | 37 ++++++++++++++++++++++++++++++++++++
src/conf/domain_conf.h | 3 +-
src/libvirt_private.syms | 2 +
src/qemu/qemu_driver.c | 35 ++++++++++++++++++++++++++++++++-
src/qemu/qemu_hotplug.c | 47 ++++++++++++---------------------------------
5 files changed, 87 insertions(+), 37 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 41726ff..a7ae604 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -7554,6 +7554,43 @@ void virDomainControllerInsertPreAlloced(virDomainDefPtr def,
def->ncontrollers++;
}
+int
+virDomainControllerFind(virDomainDefPtr def,
+ int type, int idx)
+{
+ int i;
+
+ for (i = 0 ; i < def->ncontrollers ; i++) {
+ if ((def->controllers[i]->type == type) &&
+ (def->controllers[i]->idx == idx)) {
+ return i;
+ }
+ }
+
+ return -1;
+}
+
+virDomainControllerDefPtr
+virDomainControllerRemove(virDomainDefPtr def, size_t i)
+{
+ virDomainControllerDefPtr controller = def->controllers[i];
+
+ if (def->ncontrollers > 1) {
+ memmove(def->controllers + i,
+ def->controllers + i + 1,
+ sizeof(*def->controllers) *
+ (def->ncontrollers - (i + 1)));
+ def->ncontrollers--;
+ if (VIR_REALLOC_N(def->controllers, def->ncontrollers) < 0) {
+ /* ignore, harmless */
+ }
+ } else {
+ VIR_FREE(def->controllers);
+ def->ncontrollers = 0;
+ }
+
+ return controller;
+}
int virDomainLeaseIndex(virDomainDefPtr def,
virDomainLeaseDefPtr lease)
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 469d3b6..b102a43 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2043,7 +2043,8 @@ int virDomainControllerInsert(virDomainDefPtr def,
virDomainControllerDefPtr controller);
void virDomainControllerInsertPreAlloced(virDomainDefPtr def,
virDomainControllerDefPtr controller);
-
+int virDomainControllerFind(virDomainDefPtr def, int type, int idx);
+virDomainControllerDefPtr virDomainControllerRemove(virDomainDefPtr def, size_t i);
int virDomainLeaseIndex(virDomainDefPtr def,
virDomainLeaseDefPtr lease);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 734c881..9f14077 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -266,12 +266,14 @@ virDomainClockOffsetTypeFromString;
virDomainClockOffsetTypeToString;
virDomainConfigFile;
virDomainControllerDefFree;
+virDomainControllerFind;
virDomainControllerInsert;
virDomainControllerInsertPreAlloced;
virDomainControllerModelSCSITypeFromString;
virDomainControllerModelSCSITypeToString;
virDomainControllerModelUSBTypeFromString;
virDomainControllerModelUSBTypeToString;
+virDomainControllerRemove;
virDomainControllerTypeToString;
virDomainCpuPlacementModeTypeFromString;
virDomainCpuPlacementModeTypeToString;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 6cf3882..2d9c3a9 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -5535,6 +5535,7 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef,
virDomainNetDefPtr net;
virDomainHostdevDefPtr hostdev;
virDomainLeaseDefPtr lease;
+ virDomainControllerDefPtr controller;
switch (dev->type) {
case VIR_DOMAIN_DEVICE_DISK:
@@ -5607,6 +5608,23 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef,
dev->data.lease = NULL;
break;
+ case VIR_DOMAIN_DEVICE_CONTROLLER:
+ controller = dev->data.controller;
+ if (virDomainControllerFind(vmdef, controller->type,
+ controller->idx) > 0) {
+ virReportError(VIR_ERR_INVALID_ARG, "%s",
+ _("Target already exists"));
+ return -1;
+ }
+
+ if (virDomainControllerInsert(vmdef, controller) < 0)
+ return -1;
+ dev->data.controller = NULL;
+
+ if (qemuDomainAssignAddresses(vmdef, NULL, NULL) < 0)
+ return -1;
+ break;
+
default:
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("persistent attach of device is not supported"));
@@ -5624,6 +5642,8 @@ qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef,
virDomainNetDefPtr net, det_net;
virDomainHostdevDefPtr hostdev, det_hostdev;
virDomainLeaseDefPtr lease, det_lease;
+ virDomainControllerDefPtr cont, det_cont;
+ int idx;
switch (dev->type) {
case VIR_DOMAIN_DEVICE_DISK:
@@ -5650,8 +5670,6 @@ qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef,
break;
case VIR_DOMAIN_DEVICE_HOSTDEV: {
- int idx;
-
hostdev = dev->data.hostdev;
if ((idx = virDomainHostdevFind(vmdef, hostdev, &det_hostdev)) < 0) {
virReportError(VIR_ERR_INVALID_ARG, "%s",
@@ -5674,6 +5692,19 @@ qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef,
virDomainLeaseDefFree(det_lease);
break;
+ case VIR_DOMAIN_DEVICE_CONTROLLER:
+ cont = dev->data.controller;
+ if ((idx = virDomainControllerFind(vmdef, cont->type,
+ cont->idx)) < 0) {
+ virReportError(VIR_ERR_INVALID_ARG, "%s",
+ _("device not present in domain configuration"));
+ return -1;
+ }
+ det_cont = virDomainControllerRemove(vmdef, idx);
+ virDomainControllerDefFree(det_cont);
+
+ break;
+
default:
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("persistent detach of device is not supported"));
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 7880606..c3ac938 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -308,21 +308,17 @@ int qemuDomainAttachPciControllerDevice(struct qemud_driver *driver,
virDomainObjPtr vm,
virDomainControllerDefPtr controller)
{
- int i;
int ret = -1;
const char* type = virDomainControllerTypeToString(controller->type);
char *devstr = NULL;
qemuDomainObjPrivatePtr priv = vm->privateData;
bool releaseaddr = false;
- for (i = 0 ; i < vm->def->ncontrollers ; i++) {
- if ((vm->def->controllers[i]->type == controller->type) &&
- (vm->def->controllers[i]->idx == controller->idx)) {
- virReportError(VIR_ERR_OPERATION_FAILED,
- _("target %s:%d already exists"),
- type, controller->idx);
- return -1;
- }
+ if (virDomainControllerFind(vm->def, controller->type, controller->idx) > 0) {
+ virReportError(VIR_ERR_OPERATION_FAILED,
+ _("target %s:%d already exists"),
+ type, controller->idx);
+ return -1;
}
if (qemuCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
@@ -1874,19 +1870,13 @@ int qemuDomainDetachPciControllerDevice(struct qemud_driver *driver,
virDomainObjPtr vm,
virDomainDeviceDefPtr dev)
{
- int i, ret = -1;
+ int idx, ret = -1;
virDomainControllerDefPtr detach = NULL;
qemuDomainObjPrivatePtr priv = vm->privateData;
- for (i = 0 ; i < vm->def->ncontrollers ; i++) {
- if ((vm->def->controllers[i]->type == dev->data.controller->type) &&
- (vm->def->controllers[i]->idx == dev->data.controller->idx)) {
- detach = vm->def->controllers[i];
- break;
- }
- }
-
- if (!detach) {
+ if ((idx = virDomainControllerFind(vm->def,
+ dev->data.controller->type,
+ dev->data.controller->idx)) < 0) {
virReportError(VIR_ERR_OPERATION_FAILED,
_("disk controller %s:%d not found"),
virDomainControllerTypeToString(dev->data.controller->type),
@@ -1894,6 +1884,8 @@ int qemuDomainDetachPciControllerDevice(struct qemud_driver *driver,
goto cleanup;
}
+ detach = vm->def->controllers[idx];
+
if (!virDomainDeviceAddressIsValid(&detach->info,
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI)) {
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
@@ -1934,27 +1926,14 @@ int qemuDomainDetachPciControllerDevice(struct qemud_driver *driver,
}
qemuDomainObjExitMonitorWithDriver(driver, vm);
- if (vm->def->ncontrollers > 1) {
- memmove(vm->def->controllers + i,
- vm->def->controllers + i + 1,
- sizeof(*vm->def->controllers) *
- (vm->def->ncontrollers - (i + 1)));
- vm->def->ncontrollers--;
- if (VIR_REALLOC_N(vm->def->controllers, vm->def->ncontrollers) < 0) {
- /* ignore, harmless */
- }
- } else {
- VIR_FREE(vm->def->controllers);
- vm->def->ncontrollers = 0;
- }
+ virDomainControllerRemove(vm->def, idx);
+ virDomainControllerDefFree(detach);
if (qemuCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE) &&
qemuDomainPCIAddressReleaseSlot(priv->pciaddrs,
detach->info.addr.pci.slot) < 0)
VIR_WARN("Unable to release PCI address on controller");
- virDomainControllerDefFree(detach);
-
ret = 0;
cleanup:
--
1.7.7.3
12 years, 3 months
[libvirt] [PATCH v2][TCK 2/2] Add test for memory set and get
by Kyla Zhang
Add test for memory/maxmem set and get on domain running/shutdown
---
scripts/domain/310-memory-set-get.t | 98 +++++++++++++++++++++++++++++++++++
1 files changed, 98 insertions(+), 0 deletions(-)
create mode 100644 scripts/domain/310-memory-set-get.t
diff --git a/scripts/domain/310-memory-set-get.t b/scripts/domain/310-memory-set-get.t
new file mode 100644
index 0000000..71886a6
--- /dev/null
+++ b/scripts/domain/310-memory-set-get.t
@@ -0,0 +1,98 @@
+# -*- perl -*-
+#
+# Copyright (C) 2012-2013 Red Hat, Inc.
+# Copyright (C) 2012-2013 Kyla Zhang <weizhan(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/310-memory-set-get.t: test set and get memory/max memory
+
+=head1 DESCRIPTION
+
+The test case validates that the set memory, set max memory and get
+max memory works well for domain.
+
+=cut
+
+use strict;
+use warnings;
+
+use Test::More tests => 15;
+
+use Sys::Virt::TCK;
+use Sys::Virt::TCK::NetworkHelpers;
+use Test::Exception;
+use File::Spec::Functions qw(catfile catdir rootdir);
+
+my $tck = Sys::Virt::TCK->new();
+my $conn = eval { $tck->setup(); };
+BAIL_OUT "failed to setup test harness: $@" if $@;
+END { $tck->cleanup if $tck; }
+
+diag "Define a new real domain, default memory is 1048576";
+my $dom_name ="tck310memtest";
+
+my $dom = prepare_test_disk_and_vm($tck, $conn, $dom_name);
+
+diag "Set max memory for domain";
+lives_ok(sub { $dom->set_max_memory("1572864") }, "Set max memory succeed");
+
+diag "Get max memory for domain when domain is inactive";
+is($dom->get_max_memory(), 1572864, "Get max memory is same as set value 1572864");
+
+diag "Start inactive domain";
+$dom->create;
+ok($dom->get_id() > 0, "running domain has an ID > 0");
+sleep(30);
+
+diag "Set memory for current state";
+lives_ok(sub { $dom->set_memory("924288", Sys::Virt::Domain::MEM_CONFIG) }, "Set memory succeed in persistent config");
+
+diag "get memory of running domain";
+is($dom->get_info()->{memory}, 1048576, "Get current memory is 1048576");
+
+diag "Get max memory for domain when domain is active";
+is($dom->get_max_memory(), 1572864, "Get max memory is same as set value 1572864");
+
+diag "Set memory for current state";
+lives_ok(sub { $dom->set_memory("724288", Sys::Virt::Domain::MEM_CURRENT) }, "Set memory succeed in current state");
+sleep(3);
+
+diag "Check memory of running domain";
+is($dom->get_info()->{memory}, 724288, "Get current memory is same as set value 724288");
+
+diag "Set memory for live state";
+lives_ok(sub { $dom->set_memory("824288", Sys::Virt::Domain::MEM_LIVE) }, "Set memory succeed in live state");
+sleep(3);
+
+diag "Check memory of running domain";
+is($dom->get_info()->{memory}, 824288, "Get current memory is same as set value 824288");
+
+diag "Try setting max memory when domain is running";
+ok_error(sub { $dom->set_max_memory("1048576") }, "not allowed to set max memory when domain is running");
+
+diag "Destroying the transient domain";
+$dom->destroy;
+
+diag "Check memory of shutdown domain";
+is($dom->get_info()->{memory}, 924288, "Get memory is 624288 when domain is shutdown");
+
+diag "Set max memory with set_memory";
+lives_ok(sub { $dom->set_memory("1148576", Sys::Virt::Domain::MEM_MAXIMUM) }, "Set max memory succeed with set_memory");
+
+diag "Get max memory for domain";
+is($dom->get_info()->{maxMem}, 1148576, "Get max memory is same as set value 1148576");
+
+diag "Try setting live state memory when domain is shutdown";
+ok_error(sub { $dom->set_memory("824288", Sys::Virt::Domain::MEM_LIVE) }, "not allowed to set live state memory when domain is shutdown");
--
1.7.1
12 years, 3 months
[libvirt] [PATCH] Update xml schemas according to libvirt source
by Ján Tomko
capability.rng: Guest features can be in any order.
nodedev.rng: Added <driver> element, <capability> phys_function and
virt_functions for PCI devices.
storagepool.rng: Owner or group ID can be -1.
---
docs/schemas/capability.rng | 76 +++++++++++++++++++++--------------------
docs/schemas/nodedev.rng | 37 ++++++++++++++++++++
docs/schemas/storagepool.rng | 4 +-
3 files changed, 78 insertions(+), 39 deletions(-)
diff --git a/docs/schemas/capability.rng b/docs/schemas/capability.rng
index 06ff685..c392e44 100644
--- a/docs/schemas/capability.rng
+++ b/docs/schemas/capability.rng
@@ -296,43 +296,45 @@
<define name='features'>
<element name='features'>
- <optional>
- <element name='pae'>
- <empty/>
- </element>
- </optional>
- <optional>
- <element name='nonpae'>
- <empty/>
- </element>
- </optional>
- <optional>
- <element name='ia64_be'>
- <empty/>
- </element>
- </optional>
- <optional>
- <element name='acpi'>
- <ref name='featuretoggle'/>
- <empty/>
- </element>
- </optional>
- <optional>
- <element name='apic'>
- <ref name='featuretoggle'/>
- <empty/>
- </element>
- </optional>
- <optional>
- <element name='cpuselection'>
- <empty/>
- </element>
- </optional>
- <optional>
- <element name='deviceboot'>
- <empty/>
- </element>
- </optional>
+ <interleave>
+ <optional>
+ <element name='pae'>
+ <empty/>
+ </element>
+ </optional>
+ <optional>
+ <element name='nonpae'>
+ <empty/>
+ </element>
+ </optional>
+ <optional>
+ <element name='ia64_be'>
+ <empty/>
+ </element>
+ </optional>
+ <optional>
+ <element name='acpi'>
+ <ref name='featuretoggle'/>
+ <empty/>
+ </element>
+ </optional>
+ <optional>
+ <element name='apic'>
+ <ref name='featuretoggle'/>
+ <empty/>
+ </element>
+ </optional>
+ <optional>
+ <element name='cpuselection'>
+ <empty/>
+ </element>
+ </optional>
+ <optional>
+ <element name='deviceboot'>
+ <empty/>
+ </element>
+ </optional>
+ </interleave>
</element>
</define>
diff --git a/docs/schemas/nodedev.rng b/docs/schemas/nodedev.rng
index a73c2e5..c07a97d 100644
--- a/docs/schemas/nodedev.rng
+++ b/docs/schemas/nodedev.rng
@@ -15,6 +15,12 @@
<element name="parent"><text/></element>
</optional>
+ <optional>
+ <element name="driver">
+ <element name="name"><text/></element>
+ </element>
+ </optional>
+
<zeroOrMore>
<ref name="capability"/>
</zeroOrMore>
@@ -115,6 +121,28 @@
</choice>
</element>
+ <optional>
+ <element name='capability'>
+ <attribute name='type'>
+ <value>phys_function</value>
+ </attribute>
+ <optional>
+ <ref name='address'/>
+ </optional>
+ </element>
+ </optional>
+
+ <optional>
+ <element name='capability'>
+ <attribute name='type'>
+ <value>virt_functions</value>
+ </attribute>
+ <optional>
+ <ref name='address'/>
+ </optional>
+ </element>
+ </optional>
+
</define>
<define name='capusbdev'>
@@ -369,6 +397,15 @@
</element>
</define>
+ <define name='address'>
+ <element name='address'>
+ <attribute name='domain'><ref name='hexuint'/></attribute>
+ <attribute name='bus'><ref name='hexuint'/></attribute>
+ <attribute name='slot'><ref name='hexuint'/></attribute>
+ <attribute name='function'><ref name='hexuint'/></attribute>
+ </element>
+ </define>
+
<define name='hexuint'>
<data type='string'>
<param name="pattern">(0x)?[0-9a-f]+</param>
diff --git a/docs/schemas/storagepool.rng b/docs/schemas/storagepool.rng
index 039798a..8d33f70 100644
--- a/docs/schemas/storagepool.rng
+++ b/docs/schemas/storagepool.rng
@@ -178,10 +178,10 @@
<ref name='unsignedInt'/>
</element>
<element name='owner'>
- <ref name='unsignedInt'/>
+ <data type='int'/>
</element>
<element name='group'>
- <ref name='unsignedInt'/>
+ <data type='int'/>
</element>
<optional>
<element name='label'>
--
1.7.8.6
12 years, 3 months
[libvirt] [PATCH v2][TCK 1/2] Extend image and memory size for installing guest
by Kyla Zhang
In fedora 17 with less than 512M memory will cause installation hang,
also the previous image size is too small, so improve them.
---
lib/Sys/Virt/TCK/NetworkHelpers.pm | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/Sys/Virt/TCK/NetworkHelpers.pm b/lib/Sys/Virt/TCK/NetworkHelpers.pm
index 6ff9eaa..f7f6d70 100644
--- a/lib/Sys/Virt/TCK/NetworkHelpers.pm
+++ b/lib/Sys/Virt/TCK/NetworkHelpers.pm
@@ -66,7 +66,7 @@ sub build_domain{
# We want a bigger disk than normal
$guest->rmdisk();
- my $diskpath = $tck->create_sparse_disk("nwfilter", "main.img", 2048);
+ my $diskpath = $tck->create_sparse_disk("nwfilter", "main.img", 5120);
$guest->disk(src => $diskpath,
dst => "vda",
type=> "file");
@@ -107,8 +107,8 @@ sub build_domain{
}
# common configuration
- $guest->maxmem("524288");
- $guest->memory("524288");
+ $guest->maxmem("1048576");
+ $guest->memory("1048576");
$guest->graphics(type => "vnc",
port => "-1",
autoport => "yes",
--
1.7.1
12 years, 3 months
[libvirt] [PATCH] build: don't export avahi syms when unused
by Eric Blake
Detected when building --without-avahi.
* src/libvirt_private.syms (virnetservermdns.h): Move...
* src/libvirt_avahi.syms: ...to new file.
* src/Makefile.am (USED_SYM_FILES, EXTRA_DIST): Use it.
---
I'm debating whether to push this under the build-breaker rule.
Unfortunately, while this solved my build on an Ubuntu machine,
I have other machines which are failing for other symbols (some
SASL related, and one for xenLinuxDomainBlockStats), so it's
probably better to fix everything instead of just half the problem.
src/Makefile.am | 7 ++++++-
src/libvirt_avahi.syms | 13 +++++++++++++
src/libvirt_private.syms | 13 -------------
3 files changed, 19 insertions(+), 14 deletions(-)
create mode 100644 src/libvirt_avahi.syms
diff --git a/src/Makefile.am b/src/Makefile.am
index da3d0cd..98bad3d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1344,6 +1344,10 @@ if HAVE_SASL
USED_SYM_FILES += libvirt_sasl.syms
endif
+if HAVE_AVAHI
+USED_SYM_FILES += libvirt_avahi.syms
+endif
+
EXTRA_DIST += \
libvirt_public.syms \
libvirt_private.syms \
@@ -1357,7 +1361,8 @@ EXTRA_DIST += \
libvirt_qemu.syms \
libvirt_sasl.syms \
libvirt_vmx.syms \
- libvirt_xenxs.syms
+ libvirt_xenxs.syms \
+ libvirt_avahi.syms
GENERATED_SYM_FILES = libvirt.syms libvirt.def libvirt_qemu.def
diff --git a/src/libvirt_avahi.syms b/src/libvirt_avahi.syms
new file mode 100644
index 0000000..9bfed41
--- /dev/null
+++ b/src/libvirt_avahi.syms
@@ -0,0 +1,13 @@
+# Conditional on HAVE_AVAHI
+
+# virnetservermdns.h
+virNetServerMDNSAddEntry;
+virNetServerMDNSAddGroup;
+virNetServerMDNSEntryFree;
+virNetServerMDNSFree;
+virNetServerMDNSGroupFree;
+virNetServerMDNSNew;
+virNetServerMDNSRemoveEntry;
+virNetServerMDNSRemoveGroup;
+virNetServerMDNSStart;
+virNetServerMDNSStop;
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 83ca99f..71341a2 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1541,19 +1541,6 @@ virNetServerClientStartKeepAlive;
virNetServerClientWantClose;
-# virnetservermdns.h
-virNetServerMDNSAddEntry;
-virNetServerMDNSAddGroup;
-virNetServerMDNSEntryFree;
-virNetServerMDNSFree;
-virNetServerMDNSGroupFree;
-virNetServerMDNSNew;
-virNetServerMDNSRemoveEntry;
-virNetServerMDNSRemoveGroup;
-virNetServerMDNSStart;
-virNetServerMDNSStop;
-
-
# virnetserverprogram.h
virNetServerProgramDispatch;
virNetServerProgramFree;
--
1.7.11.2
12 years, 3 months
[libvirt] [PATCH] virsh: Switch to close callback
by Michal Privoznik
Since we've introduced close callbacks we can drop this SIGINT magic
(which doesn't work now neither) and fully utilize the new feature.
---
tools/virsh.c | 45 ++++++++++++++++-----------------------------
1 files changed, 16 insertions(+), 29 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 4670ee6..b95a008 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -568,31 +568,16 @@ static int disconnected = 0; /* we may have been disconnected */
/*
* vshCatchDisconnect:
*
- * We get here when a SIGPIPE is being raised, we can't do much in the
- * handler, just save the fact it was raised
- */
-static void vshCatchDisconnect(int sig, siginfo_t *siginfo,
- void *context ATTRIBUTE_UNUSED) {
- if (sig == SIGPIPE ||
- (SA_SIGINFO && siginfo->si_signo == SIGPIPE))
- disconnected++;
-}
-
-/*
- * vshSetupSignals:
- *
- * Catch SIGPIPE signals which may arise when disconnection
- * from libvirtd occurs
+ * We get here when the connection was closed. We can't do much in the
+ * handler, just save the fact it was raised.
*/
static void
-vshSetupSignals(void) {
- struct sigaction sig_action;
-
- sig_action.sa_sigaction = vshCatchDisconnect;
- sig_action.sa_flags = SA_SIGINFO;
- sigemptyset(&sig_action.sa_mask);
-
- sigaction(SIGPIPE, &sig_action, NULL);
+vshCatchDisconnect(virConnectPtr conn ATTRIBUTE_UNUSED,
+ int reason,
+ void *opaque ATTRIBUTE_UNUSED)
+{
+ if (reason != VIR_CONNECT_CLOSE_REASON_CLIENT)
+ disconnected++;
}
/*
@@ -614,10 +599,15 @@ vshReconnect(vshControl *ctl)
ctl->conn = virConnectOpenAuth(ctl->name,
virConnectAuthPtrDefault,
ctl->readonly ? VIR_CONNECT_RO : 0);
- if (!ctl->conn)
+ if (!ctl->conn) {
vshError(ctl, "%s", _("Failed to reconnect to the hypervisor"));
- else if (connected)
- vshError(ctl, "%s", _("Reconnected to the hypervisor"));
+ } else {
+ if (virConnectRegisterCloseCallback(ctl->conn, vshCatchDisconnect,
+ NULL, NULL) < 0)
+ vshError(ctl, "%s", _("Unable to register disconnect callback"));
+ if (connected)
+ vshError(ctl, "%s", _("Reconnected to the hypervisor"));
+ }
disconnected = 0;
ctl->useGetInfo = false;
ctl->useSnapshotOld = false;
@@ -2458,9 +2448,6 @@ vshInit(vshControl *ctl)
/* set up the library error handler */
virSetErrorFunc(NULL, virshErrorHandler);
- /* set up the signals handlers to catch disconnections */
- vshSetupSignals();
-
if (virEventRegisterDefaultImpl() < 0)
return false;
--
1.7.8.6
12 years, 3 months