[libvirt] [PATCH go] Add support for virStorageVolGetInfoFlags & associated constants
by Daniel P. Berrange
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
storage_volume.go | 24 ++++++++++++++++++++++++
storage_volume_compat.go | 47 +++++++++++++++++++++++++++++++++++++++++++++++
storage_volume_compat.h | 15 +++++++++++++++
3 files changed, 86 insertions(+)
create mode 100644 storage_volume_compat.go
Pushed as a build fix
diff --git a/storage_volume.go b/storage_volume.go
index 80b74fa..317a1dd 100644
--- a/storage_volume.go
+++ b/storage_volume.go
@@ -94,6 +94,13 @@ const (
STORAGE_XML_INACTIVE = StorageXMLFlags(C.VIR_STORAGE_XML_INACTIVE)
)
+type StorageVolInfoFlags int
+
+const (
+ STORAGE_VOL_USE_ALLOCATION = StorageVolInfoFlags(C.VIR_STORAGE_VOL_USE_ALLOCATION)
+ STORAGE_VOL_GET_PHYSICAL = StorageVolInfoFlags(C.VIR_STORAGE_VOL_GET_PHYSICAL)
+)
+
type StorageVol struct {
ptr C.virStorageVolPtr
}
@@ -133,6 +140,23 @@ func (v *StorageVol) GetInfo() (*StorageVolInfo, error) {
}, nil
}
+func (v *StorageVol) GetInfoFlags(flags StorageVolInfoFlags) (*StorageVolInfo, error) {
+ if C.LIBVIR_VERSION_NUMBER < 3000000 {
+ return nil, GetNotImplementedError()
+ }
+
+ var cinfo C.virStorageVolInfo
+ result := C.virStorageVolGetInfoFlagsCompat(v.ptr, &cinfo, C.uint(flags))
+ if result == -1 {
+ return nil, GetLastError()
+ }
+ return &StorageVolInfo{
+ Type: StorageVolType(cinfo._type),
+ Capacity: uint64(cinfo.capacity),
+ Allocation: uint64(cinfo.allocation),
+ }, nil
+}
+
func (v *StorageVol) GetKey() (string, error) {
key := C.virStorageVolGetKey(v.ptr)
if key == nil {
diff --git a/storage_volume_compat.go b/storage_volume_compat.go
new file mode 100644
index 0000000..46f0e0b
--- /dev/null
+++ b/storage_volume_compat.go
@@ -0,0 +1,47 @@
+/*
+ * This file is part of the libvirt-go project
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * Copyright (c) 2013 Alex Zorin
+ * Copyright (C) 2016 Red Hat, Inc.
+ *
+ */
+
+package libvirt
+
+/*
+#cgo pkg-config: libvirt
+#include <libvirt/libvirt.h>
+#include <assert.h>
+#include "storage_volume_compat.h"
+
+int virStorageVolGetInfoFlagsCompat(virStorageVolPtr vol,
+ virStorageVolInfoPtr info,
+ unsigned int flags)
+{
+#if LIBVIR_VERSION_NUMBER < 3000000
+ assert(0); // Caller should have checked version
+#else
+ return virStorageVolGetInfoFlags(vol, info, flags);
+#endif
+}
+
+*/
+import "C"
diff --git a/storage_volume_compat.h b/storage_volume_compat.h
index 2c07445..53e83fe 100644
--- a/storage_volume_compat.h
+++ b/storage_volume_compat.h
@@ -27,6 +27,21 @@
#ifndef LIBVIRT_GO_STORAGE_VOLUME_COMPAT_H__
#define LIBVIRT_GO_STORAGE_VOLUME_COMPAT_H__
+/* 3.0.0 */
+
+int virStorageVolGetInfoFlagsCompat(virStorageVolPtr vol,
+ virStorageVolInfoPtr info,
+ unsigned int flags);
+
+#ifndef VIR_STORAGE_VOL_USE_ALLOCATION
+#define VIR_STORAGE_VOL_USE_ALLOCATION 0
+#endif
+
+#ifndef VIR_STORAGE_VOL_GET_PHYSICAL
+#define VIR_STORAGE_VOL_GET_PHYSICAL 1 << 0
+#endif
+
+
/* 1.2.13 */
#ifndef VIR_STORAGE_VOL_CREATE_REFLINK
--
2.9.3
7 years, 11 months
[libvirt] [PATCH] Add virStorageVolGetInfoFlags & associated constants
by Daniel P. Berrange
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
Changes | 1 +
Virt.xs | 16 ++++++++++++----
lib/Sys/Virt/StorageVol.pm | 16 ++++++++++++++--
3 files changed, 27 insertions(+), 6 deletions(-)
Pushed as a build fix
diff --git a/Changes b/Changes
index 48ac221..672b566 100644
--- a/Changes
+++ b/Changes
@@ -9,6 +9,7 @@ Revision history for perl module Sys::Virt
- Add PERF_PARAM_STALLED_CYCLES_FRONTEND constant
- Add PERF_PARAM_STALLED_CYCLES_BACKEND constant
- Add PERF_PARAM_REF_CPU_CYCLES constant
+ - Add virStorageVolGetInfoFlags & associated constants
2.5.0 2016-12-05
diff --git a/Virt.xs b/Virt.xs
index d694eff..1eb94a8 100644
--- a/Virt.xs
+++ b/Virt.xs
@@ -1,6 +1,6 @@
/* -*- c -*-
*
- * Copyright (C) 2006-2014 Red Hat
+ * Copyright (C) 2006-2016 Red Hat
* Copyright (C) 2006-2014 Daniel P. Berrange
*
* This program is free software; You can redistribute it and/or modify
@@ -6630,13 +6630,19 @@ wipe_pattern(vol, algorithm, flags=0)
HV *
-get_info(vol)
+get_info(vol, flags=0)
virStorageVolPtr vol;
+ unsigned int flags;
PREINIT:
virStorageVolInfo info;
CODE:
- if (virStorageVolGetInfo(vol, &info) < 0)
- _croak_error();
+ if (flags != 0) {
+ if (virStorageVolGetInfoFlags(vol, &info, flags) < 0)
+ _croak_error();
+ } else {
+ if (virStorageVolGetInfo(vol, &info) < 0)
+ _croak_error();
+ }
RETVAL = (HV *)sv_2mortal((SV*)newHV());
(void)hv_store (RETVAL, "type", 4, newSViv(info.type), 0);
@@ -8701,6 +8707,8 @@ BOOT:
REGISTER_CONSTANT(VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA, CREATE_PREALLOC_METADATA);
REGISTER_CONSTANT(VIR_STORAGE_VOL_CREATE_REFLINK, CREATE_REFLINK);
+ REGISTER_CONSTANT(VIR_STORAGE_VOL_USE_ALLOCATION, USE_ALLOCATION);
+ REGISTER_CONSTANT(VIR_STORAGE_VOL_GET_PHYSICAL, GET_PHYSICAL);
stash = gv_stashpv( "Sys::Virt::Secret", TRUE );
REGISTER_CONSTANT(VIR_SECRET_USAGE_TYPE_NONE, USAGE_TYPE_NONE);
diff --git a/lib/Sys/Virt/StorageVol.pm b/lib/Sys/Virt/StorageVol.pm
index d293bfa..42f10e8 100644
--- a/lib/Sys/Virt/StorageVol.pm
+++ b/lib/Sys/Virt/StorageVol.pm
@@ -118,7 +118,7 @@ to erase data, and should be one of the WIPE ALGORITHM CONSTANTS
listed later. The C<flags> parameter is currently unused and defaults
to zero.
-=item my $info = $vol->get_info()
+=item my $info = $vol->get_info($flags = 0)
Retrieve live information about the storage volume. The returned
C<$info> hash reference contains three keys. C<type> indicates whether
@@ -127,7 +127,19 @@ logical size of the volume. C<allocation> provides the current
physical usage of the volume. The allocation may be less than the
capacity for sparse, or grow-on-demand volumes. The allocation
may also be larger than the capacity, if there is a metadata overhead
-for the volume format.
+for the volume format. C<$flags> may take one of the values
+
+=over 4
+
+=item Sys::Virt::StorageVol::USE_ALLOCATION
+
+Return the current allocation in allocation
+
+=item Sys::Virt::StorageVol::GET_PHYSICAL
+
+Return the physical size in allocation
+
+=back
=item $vol->download($st, $offset, $length);
--
2.9.3
7 years, 11 months
[libvirt] [PATCH] Add override impl for virStorageVolGetInfoFlags
by Daniel P. Berrange
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
generator.py | 1 +
libvirt-override-api.xml | 6 ++++++
libvirt-override.c | 43 +++++++++++++++++++++++++++++++++++++++++++
3 files changed, 50 insertions(+)
Pushed as a build fix patch
diff --git a/generator.py b/generator.py
index 2c3b667..afb1d34 100755
--- a/generator.py
+++ b/generator.py
@@ -455,6 +455,7 @@ skip_impl = (
'virStoragePoolLookupByUUID',
'virStoragePoolGetInfo',
'virStorageVolGetInfo',
+ 'virStorageVolGetInfoFlags',
'virStoragePoolGetAutostart',
'virStoragePoolListVolumes',
'virDomainBlockPeek',
diff --git a/libvirt-override-api.xml b/libvirt-override-api.xml
index 50250bc..c96e83e 100644
--- a/libvirt-override-api.xml
+++ b/libvirt-override-api.xml
@@ -410,6 +410,12 @@
<return type='char *' info='the list of information or None in case of error'/>
<arg name='vol' type='virStorageVolPtr' info='a storage vol object'/>
</function>
+ <function name='virStorageVolGetInfoFlags' file='python'>
+ <info>Extract information about a storage volume. Note that if the connection used to get the domain is limited only a partial set of the information can be extracted.</info>
+ <return type='char *' info='the list of information or None in case of error'/>
+ <arg name='vol' type='virStorageVolPtr' info='a storage vol object'/>
+ <arg name='flags' type='unsigned int' info='bitwise-OR of virStorageVolInfoFlags'/>
+ </function>
<function name='virNodeListDevices' file='python'>
<info>list the node devices</info>
<arg name='conn' type='virConnectPtr' info='pointer to the hypervisor connection'/>
diff --git a/libvirt-override.c b/libvirt-override.c
index be299d4..db14244 100644
--- a/libvirt-override.c
+++ b/libvirt-override.c
@@ -3681,6 +3681,46 @@ libvirt_virStorageVolGetInfo(PyObject *self ATTRIBUTE_UNUSED,
return NULL;
}
+#if LIBVIR_CHECK_VERSION(3, 0, 0)
+static PyObject *
+libvirt_virStorageVolGetInfoFlags(PyObject *self ATTRIBUTE_UNUSED,
+ PyObject *args)
+{
+ PyObject *py_retval;
+ int c_retval;
+ virStorageVolPtr pool;
+ PyObject *pyobj_pool;
+ virStorageVolInfo info;
+ unsigned int flags;
+
+ if (!PyArg_ParseTuple(args, (char *)"OI:virStorageVolGetInfoFlags", &pyobj_pool, &flags))
+ return NULL;
+ pool = (virStorageVolPtr) PyvirStorageVol_Get(pyobj_pool);
+
+ LIBVIRT_BEGIN_ALLOW_THREADS;
+ c_retval = virStorageVolGetInfoFlags(pool, &info, flags);
+ LIBVIRT_END_ALLOW_THREADS;
+ if (c_retval < 0)
+ return VIR_PY_NONE;
+
+ if ((py_retval = PyList_New(3)) == NULL)
+ return NULL;
+
+ VIR_PY_LIST_SET_GOTO(py_retval, 0,
+ libvirt_intWrap((int) info.type), error);
+ VIR_PY_LIST_SET_GOTO(py_retval, 1,
+ libvirt_ulonglongWrap(info.capacity), error);
+ VIR_PY_LIST_SET_GOTO(py_retval, 2,
+ libvirt_ulonglongWrap(info.allocation), error);
+
+ return py_retval;
+
+ error:
+ Py_DECREF(py_retval);
+ return NULL;
+}
+#endif
+
static PyObject *
libvirt_virStoragePoolGetUUID(PyObject *self ATTRIBUTE_UNUSED,
PyObject *args)
@@ -9203,6 +9243,9 @@ static PyMethodDef libvirtMethods[] = {
#endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
{(char *) "virStoragePoolGetInfo", libvirt_virStoragePoolGetInfo, METH_VARARGS, NULL},
{(char *) "virStorageVolGetInfo", libvirt_virStorageVolGetInfo, METH_VARARGS, NULL},
+#if LIBVIR_CHECK_VERSION(3, 0, 0)
+ {(char *) "virStorageVolGetInfoFlags", libvirt_virStorageVolGetInfoFlags, METH_VARARGS, NULL},
+#endif /* LIBVIR_CHECK_VERSION(3, 0, 0) */
{(char *) "virStoragePoolGetUUID", libvirt_virStoragePoolGetUUID, METH_VARARGS, NULL},
{(char *) "virStoragePoolGetUUIDString", libvirt_virStoragePoolGetUUIDString, METH_VARARGS, NULL},
{(char *) "virStoragePoolLookupByUUID", libvirt_virStoragePoolLookupByUUID, METH_VARARGS, NULL},
--
2.9.3
7 years, 11 months
[libvirt] [RFC] add option to bring new qemu binary/pending conf changes on reboot
by Nikolay Shirokovskiy
Hi, all.
I'm trying to reword the long pending RFC [1]. We interested in next usecase.
Administrator update qemu binary/make domain configuration changes that
transparent to the guest. This changes are not applied until domain shutdown/started
by domain user. Sometimes user just reboots domain and these changes as they
transparent can be applied too and this is a good opportunity to apply changes.
For example new qemu binary have some optimizations and administrator would
like to use these optimizations and don't want to force user to restart, waiting
for user reboot is considered good enough.
To support this use case we can add 'recreate' option to on_reboot/on_shutdown event.
[1] https://www.redhat.com/archives/libvir-list/2016-June/msg02259.html
7 years, 11 months
[libvirt] [PATCH] Remove bogus \o escape in regex
by Daniel P. Berrange
One of the regexes has a bogus \o instead of plain 'o'. Somehow
this magically worked on all versions of python, until 3.6 came
along and complained
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
generator.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Pushed as a trival fix / python 3.6 build fix
diff --git a/generator.py b/generator.py
index 730e456..2c3b667 100755
--- a/generator.py
+++ b/generator.py
@@ -1091,7 +1091,7 @@ def is_integral_type (name):
return not re.search ("^(unsigned)? ?(int|long)$", name) is None
def is_optional_arg(info):
- return re.search("^\(?\optional\)?", info) is not None
+ return re.search("^\(?optional\)?", info) is not None
# Functions returning lists which need special rules to check for errors
# and raise exceptions.
functions_list_exception_test = {
--
2.9.3
7 years, 11 months
[libvirt] [PATCH v3] qemu: report block job errors from qemu to the user
by Nikolay Shirokovskiy
So that you can see nice report on migration:
"error: operation failed: migration of disk sda failed: No space left on device"
diff from v2:
1. split into 2 patches
2. change formal documentation where it is present accordingly
3. add variable initialization for safety
Nikolay Shirokovskiy (2):
qemu: prepare blockjob complete event error usage
qemu: report drive mirror errors on migration
src/qemu/qemu_blockjob.c | 14 ++++++++++--
src/qemu/qemu_blockjob.h | 3 ++-
src/qemu/qemu_domain.c | 1 +
src/qemu/qemu_domain.h | 1 +
src/qemu/qemu_driver.c | 4 ++--
src/qemu/qemu_migration.c | 54 +++++++++++++++++++++++++++++++-------------
src/qemu/qemu_monitor.c | 5 ++--
src/qemu/qemu_monitor.h | 4 +++-
src/qemu/qemu_monitor_json.c | 4 +++-
src/qemu/qemu_process.c | 4 ++++
10 files changed, 69 insertions(+), 25 deletions(-)
--
1.8.3.1
7 years, 11 months
[libvirt] [PATCH] apparmor: pass attach_disconnected
by Guido Günther
to cure
+ virsh lxc-enter-namespace --noseclabel <container> <cmd>
libvirt: error : Expected at least one file descriptor
error: internal error: Child process (2714) unexpected exit status 125
caused by
apparmor="DENIED" operation="open" info="Failed name lookup - disconnected path" error=-13 profile="/usr/sbin/libvirtd" name="" pid=1422 comm="libvirtd" requested_mask="r" denied_mask="r" fsuid=0 ouid=0
---
Thanks to intrigeri for the suggestion!
examples/apparmor/usr.sbin.libvirtd | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/examples/apparmor/usr.sbin.libvirtd b/examples/apparmor/usr.sbin.libvirtd
index 48651b28f..b7e47f5c3 100644
--- a/examples/apparmor/usr.sbin.libvirtd
+++ b/examples/apparmor/usr.sbin.libvirtd
@@ -2,7 +2,7 @@
#include <tunables/global>
@{LIBVIRT}="libvirt"
-/usr/sbin/libvirtd {
+/usr/sbin/libvirtd flags=(attach_disconnected) {
#include <abstractions/base>
#include <abstractions/dbus>
--
2.11.0
7 years, 11 months
[libvirt] [PATCH v2] xen: add QED format test
by Cédric Bosdonnat
Follow up of commit 340bb6b7 to add unit tests for the QED format
support. Also add missing QED case in xenFormatXLDisk()
---
v2:
* Separated the QED test files into another set ti make this
test conditionnal
* Removed useless #ifdef
src/xenconfig/xen_xl.c | 3 +++
tests/xlconfigdata/test-disk-qed.cfg | 25 ++++++++++++++++++++
tests/xlconfigdata/test-disk-qed.xml | 45 ++++++++++++++++++++++++++++++++++++
tests/xlconfigtest.c | 3 +++
4 files changed, 76 insertions(+)
create mode 100644 tests/xlconfigdata/test-disk-qed.cfg
create mode 100644 tests/xlconfigdata/test-disk-qed.xml
diff --git a/src/xenconfig/xen_xl.c b/src/xenconfig/xen_xl.c
index 048ecd579..18d9fe369 100644
--- a/src/xenconfig/xen_xl.c
+++ b/src/xenconfig/xen_xl.c
@@ -1050,6 +1050,9 @@ xenFormatXLDisk(virConfValuePtr list, virDomainDiskDefPtr disk)
case VIR_STORAGE_FILE_QCOW2:
virBufferAddLit(&buf, "qcow2");
break;
+ case VIR_STORAGE_FILE_QED:
+ virBufferAddLit(&buf, "qed");
+ break;
/* set default */
default:
virBufferAddLit(&buf, "raw");
diff --git a/tests/xlconfigdata/test-disk-qed.cfg b/tests/xlconfigdata/test-disk-qed.cfg
new file mode 100644
index 000000000..2a2c4fa84
--- /dev/null
+++ b/tests/xlconfigdata/test-disk-qed.cfg
@@ -0,0 +1,25 @@
+name = "XenGuest2"
+uuid = "c7a5fdb2-cdaf-9455-926a-d65c16db1809"
+maxmem = 579
+memory = 394
+vcpus = 1
+pae = 1
+acpi = 1
+apic = 1
+viridian = 0
+rtc_timeoffset = 0
+localtime = 0
+on_poweroff = "destroy"
+on_reboot = "restart"
+on_crash = "restart"
+device_model = "/usr/lib/xen/bin/qemu-system-i386"
+sdl = 0
+vnc = 1
+vncunused = 1
+vnclisten = "127.0.0.1"
+vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge,model=e1000" ]
+parallel = "none"
+serial = "none"
+builder = "hvm"
+boot = "d"
+disk = [ "/var/lib/libvirt/images/XenGuest2,qed,hda,rw", ]
diff --git a/tests/xlconfigdata/test-disk-qed.xml b/tests/xlconfigdata/test-disk-qed.xml
new file mode 100644
index 000000000..230382dd5
--- /dev/null
+++ b/tests/xlconfigdata/test-disk-qed.xml
@@ -0,0 +1,45 @@
+<domain type='xen'>
+ <name>XenGuest2</name>
+ <uuid>c7a5fdb2-cdaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>592896</memory>
+ <currentMemory unit='KiB'>403456</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='x86_64' machine='xenfv'>hvm</type>
+ <loader type='rom'>/usr/lib/xen/boot/hvmloader</loader>
+ <boot dev='cdrom'/>
+ </os>
+ <features>
+ <acpi/>
+ <apic/>
+ <pae/>
+ </features>
+ <clock offset='variable' adjustment='0' basis='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>restart</on_crash>
+ <devices>
+ <emulator>/usr/lib/xen/bin/qemu-system-i386</emulator>
+ <disk type='file' device='disk'>
+ <driver name='qemu' type='qed'/>
+ <source file='/var/lib/libvirt/images/XenGuest2'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+ </disk>
+ <controller type='ide' index='0'/>
+ <interface type='bridge'>
+ <mac address='00:16:3e:66:92:9c'/>
+ <source bridge='xenbr1'/>
+ <script path='vif-bridge'/>
+ <model type='e1000'/>
+ </interface>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1'>
+ <listen type='address' address='127.0.0.1'/>
+ </graphics>
+ <video>
+ <model type='cirrus' vram='8192' heads='1' primary='yes'/>
+ </video>
+ </devices>
+</domain>
diff --git a/tests/xlconfigtest.c b/tests/xlconfigtest.c
index 31892da69..cab0c0d47 100644
--- a/tests/xlconfigtest.c
+++ b/tests/xlconfigtest.c
@@ -258,6 +258,9 @@ mymain(void)
DO_TEST("new-disk");
DO_TEST_FORMAT("disk-positional-parms-full", false);
DO_TEST_FORMAT("disk-positional-parms-partial", false);
+#ifdef LIBXL_HAVE_QED
+ DO_TEST_FORMAT("disk-qed", false);
+#endif
DO_TEST("spice");
DO_TEST("spice-features");
DO_TEST("vif-rate");
--
2.11.0
7 years, 11 months