[libvirt] [PATCH v2 0/2] libvirt-python: libvirtaio
by Wojtek Porczyk
Hello, libvirt-list,
This is second attempt at merging libvirtaio, an event loop implementation
which dispatches the callbacks via asyncio's event loop.
The first patch fixes the bug around freeing opaque objects [1][2], and the
second one is the actual implementation.
Since v1 series, as per Daniel Berrange's notes, the second patch has licence
comment changed to LGPL-2.1+ and there is no import into main libvirt module.
The first patch is unchanged.
[1] https://www.redhat.com/archives/libvir-list/2017-January/msg00863.html
[2] https://bugzilla.redhat.com/show_bug.cgi?id=1433028
Wojtek Porczyk (2):
Allow for ff callbacks to be called by custom event implementations
Add asyncio event loop implementation
libvirt-override.c | 36 ++---
libvirt-override.py | 39 +++++
libvirt-python.spec.in | 1 +
libvirtaio.py | 401 +++++++++++++++++++++++++++++++++++++++++++++++++
sanitytest.py | 5 +-
setup.py | 12 ++
6 files changed, 468 insertions(+), 26 deletions(-)
create mode 100644 libvirtaio.py
--
pozdrawiam / best regards _.-._
Wojtek Porczyk .-^' '^-.
Invisible Things Lab |'-.-^-.-'|
| | | |
I do not fear computers, | '-.-' |
I fear lack of them. '-._ : ,-'
-- Isaac Asimov `^-^-_>
7 years, 12 months
[libvirt] [PATCH v2 0/5] Fix gluster pool lookup issues
by Peter Krempa
Peter Krempa (5):
storage: util: Add boolean differentiating between gluster lookup type
storage: util: Split out the gluster volume extraction code into new
function
test: Introduce testing of virStorageUtilGlusterExtractPoolSources
storage: Fix XPath for looking up gluster volume name
storage: gluster: Use volume name as "<name>" field in the XML
src/storage/storage_backend_fs.c | 5 +-
src/storage/storage_backend_gluster.c | 3 +-
src/storage/storage_util.c | 110 ++++++++++++--------
src/storage/storage_util.h | 6 +-
tests/Makefile.am | 15 ++-
.../gluster-parse-basic-native.xml | 7 ++
.../gluster-parse-basic-netfs.xml | 7 ++
.../virstorageutildata/gluster-parse-basic-src.xml | 47 +++++++++
.../gluster-parse-multivol-native.xml | 17 +++
.../gluster-parse-multivol-netfs.xml | 17 +++
.../gluster-parse-multivol-src.xml | 32 ++++++
tests/virstorageutiltest.c | 114 +++++++++++++++++++++
12 files changed, 330 insertions(+), 50 deletions(-)
create mode 100644 tests/virstorageutildata/gluster-parse-basic-native.xml
create mode 100644 tests/virstorageutildata/gluster-parse-basic-netfs.xml
create mode 100644 tests/virstorageutildata/gluster-parse-basic-src.xml
create mode 100644 tests/virstorageutildata/gluster-parse-multivol-native.xml
create mode 100644 tests/virstorageutildata/gluster-parse-multivol-netfs.xml
create mode 100644 tests/virstorageutildata/gluster-parse-multivol-src.xml
create mode 100644 tests/virstorageutiltest.c
--
2.12.1
7 years, 12 months
[libvirt] [PATCH 0/5] qemu: fix individual vcpu hotplug code
by Peter Krempa
Resolve a few corner cases which would create invalid configurations or produce
bad error messages.
Peter Krempa (5):
qemu: hotplug: Iterate over vcpu 0 in individual vcpu hotplug code
qemu: hotplug: Fix formatting strings in
qemuDomainFilterHotplugVcpuEntities
qemu: hotplug: Clear vcpu ordering for coldplug of vcpus
qemu: hotplug: Add validation for coldplug of individual vcpus
qemu: hotplug: Validate that vcpu-hotplug does not break config
src/qemu/qemu_hotplug.c | 73 +++++++++++++++++++++++++++++++++++++++++++------
1 file changed, 65 insertions(+), 8 deletions(-)
--
2.12.2
7 years, 12 months
[libvirt] [PATCH v2] virNetDevIPCheckIPv6ForwardingCallback fixes
by Cédric Bosdonnat
Add check for more than one RTA_OIF, even though this is rather
unlikely.
Get rid of the buggy switch / break as this code won't need to
handle more attributes.
Use VIR_WARNINGS_NO_CAST_ALIGN to fix impossible to fix
util/virnetdevip.c:560:17: error: cast increases required alignment of target type [-Werror=cast-align]
---
Diff to v1:
* Add error message
* Use VIR_WARNINGS_NO_CAST_ALIGN
src/util/virnetdevip.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/src/util/virnetdevip.c b/src/util/virnetdevip.c
index c9ac6baf7..726fa6c3e 100644
--- a/src/util/virnetdevip.c
+++ b/src/util/virnetdevip.c
@@ -556,15 +556,24 @@ virNetDevIPCheckIPv6ForwardingCallback(const struct nlmsghdr *resp,
if (resp->nlmsg_type != RTM_NEWROUTE)
return ret;
- /* Extract a few attributes */
+ /* Extract a device ID attribute */
+ VIR_WARNINGS_NO_CAST_ALIGN
for (rta = RTM_RTA(rtmsg); RTA_OK(rta, len); rta = RTA_NEXT(rta, len)) {
- switch (rta->rta_type) {
- case RTA_OIF:
+ VIR_WARNINGS_RESET
+ if (rta->rta_type == RTA_OIF) {
oif = *(int *)RTA_DATA(rta);
+ /* Should never happen: netlink message would be broken */
+ if (ifname) {
+ char *ifname2 = virNetDevGetName(oif);
+ VIR_WARN("Single route has unexpected 2nd interface "
+ "- '%s' and '%s'", ifname, ifname2);
+ VIR_FREE(ifname2);
+ break;
+ }
+
if (!(ifname = virNetDevGetName(oif)))
goto error;
- break;
}
}
--
2.12.0
7 years, 12 months
[libvirt] [PATCH 0/5] Split out network object into its own module
by John Ferlan
Reached the last of the code from my RFC for making a common pool
object - networkobj... For reference see patch 3 of:
http://www.redhat.com/archives/libvir-list/2017-February/msg00519.html
This series works through the network conf adjustments. This pile is
fairly straightforward, like other series we split out anything referencing
virNetworkPoolObj and go from there. There was one small detour to avoid
a potentially conflict in names.
John Ferlan (5):
conf: Introduce virnetworkobj
conf: Adjust coding style for network conf sources
conf: Alter coding style of network conf function prototypes
conf: Rename virNetworkObjAssignDef to virNetworkObjUpdateAssignDef
conf: Use consistent function name prefixes for virnetworkobj
po/POTFILES.in | 1 +
src/Makefile.am | 3 +-
src/conf/network_conf.c | 1387 ++--------------------------------
src/conf/network_conf.h | 204 ++---
src/conf/virnetworkobj.c | 1371 +++++++++++++++++++++++++++++++++
src/conf/virnetworkobj.h | 185 +++++
src/libvirt_private.syms | 57 +-
src/network/bridge_driver.c | 62 +-
src/network/bridge_driver.h | 2 +-
src/network/bridge_driver_platform.h | 2 +-
src/test/test_driver.c | 16 +-
11 files changed, 1762 insertions(+), 1528 deletions(-)
create mode 100644 src/conf/virnetworkobj.c
create mode 100644 src/conf/virnetworkobj.h
--
2.9.3
7 years, 12 months
[libvirt] [libvirt-perl][PATCH 0/3] Reflect upstream changes
by Michal Privoznik
Couple of new APIs and constants were added to libvirt.
Reflect them in the perl bindings.
Michal Privoznik (3):
Add block threshold event
Add virDomainSetBlockThreshold API
Add VIR_MIGRATE_TLS constant
Changes | 3 +++
Virt.xs | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++
lib/Sys/Virt/Domain.pm | 22 ++++++++++++++++++
t/030-api-coverage.t | 1 +
4 files changed, 87 insertions(+)
--
2.10.2
7 years, 12 months
[libvirt] [PATCH] storage: Fix capacity value for LUKS encrypted volumes
by John Ferlan
https://bugzilla.redhat.com/show_bug.cgi?id=1371892
The 'capacity' value (e.g. guest logical size) for a LUKS volume is
smaller than the 'physical' value of the file in the file system, so
we need to account for that.
When peeking at the encryption information about the volume add a fetch
of the payload_offset which is described as the offset to the start of
the volume data (in 512 byte sectors) in QEMU's QCryptoBlockLUKSHeader.
Then adjust the ->capacity appropriately when we determine that the
volume target encryption has a payload_offset value.
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
src/storage/storage_util.c | 3 +++
src/util/virstorageencryption.h | 1 +
src/util/virstoragefile.c | 39 +++++++++++++++++++++++++++++++++++++++
3 files changed, 43 insertions(+)
diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c
index 38d373e..213f173 100644
--- a/src/storage/storage_util.c
+++ b/src/storage/storage_util.c
@@ -3436,6 +3436,9 @@ storageBackendProbeTarget(virStorageSourcePtr target,
target->capacity = meta->capacity;
if (encryption && meta->encryption) {
+ if (meta->encryption->payload_offset != -1)
+ target->capacity -= meta->encryption->payload_offset * 512;
+
*encryption = meta->encryption;
meta->encryption = NULL;
diff --git a/src/util/virstorageencryption.h b/src/util/virstorageencryption.h
index fa439fb..42f990c 100644
--- a/src/util/virstorageencryption.h
+++ b/src/util/virstorageencryption.h
@@ -70,6 +70,7 @@ typedef struct _virStorageEncryption virStorageEncryption;
typedef virStorageEncryption *virStorageEncryptionPtr;
struct _virStorageEncryption {
int format; /* virStorageEncryptionFormatType */
+ int payload_offset;
size_t nsecrets;
virStorageEncryptionSecretPtr *secrets;
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index c9420fd..7b30143 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -133,6 +133,8 @@ struct FileEncryptionInfo {
int modeOffset; /* Byte offset of the format native encryption mode */
char modeValue; /* Value expected at offset */
+
+ int payloadOffset; /* start offset of the volume data (in 512 byte sectors) */
};
/* Either 'magic' or 'extension' *must* be provided */
@@ -212,9 +214,18 @@ qedGetBackingStore(char **, int *, const char *, size_t);
#define LUKS_HDR_MAGIC_LEN 6
#define LUKS_HDR_VERSION_LEN 2
+#define LUKS_HDR_CIPHER_NAME_LEN 32
+#define LUKS_HDR_CIPHER_MODE_LEN 32
+#define LUKS_HDR_HASH_SPEC_LEN 32
+#define LUKS_HDR_PAYLOAD_LEN 4
/* Format described by qemu commit id '3e308f20e' */
#define LUKS_HDR_VERSION_OFFSET LUKS_HDR_MAGIC_LEN
+#define LUKS_HDR_PAYLOAD_OFFSET (LUKS_HDR_MAGIC_LEN+\
+ LUKS_HDR_VERSION_LEN+\
+ LUKS_HDR_CIPHER_NAME_LEN+\
+ LUKS_HDR_CIPHER_MODE_LEN+\
+ LUKS_HDR_HASH_SPEC_LEN)
static struct FileEncryptionInfo const luksEncryptionInfo[] = {
{
@@ -231,6 +242,8 @@ static struct FileEncryptionInfo const luksEncryptionInfo[] = {
.modeOffset = -1,
.modeValue = -1,
+
+ .payloadOffset = LUKS_HDR_PAYLOAD_OFFSET,
},
{ 0 }
};
@@ -249,6 +262,8 @@ static struct FileEncryptionInfo const qcow1EncryptionInfo[] = {
.modeOffset = QCOW1_HDR_CRYPT,
.modeValue = 1,
+
+ .payloadOffset = -1,
},
{ 0 }
};
@@ -267,6 +282,8 @@ static struct FileEncryptionInfo const qcow2EncryptionInfo[] = {
.modeOffset = QCOW2_HDR_CRYPT,
.modeValue = 1,
+
+ .payloadOffset = -1,
},
{ 0 }
};
@@ -921,6 +938,23 @@ virStorageFileHasEncryptionFormat(const struct FileEncryptionInfo *info,
}
+static int
+virStorageFileGetEncryptionPayloadOffset(const struct FileEncryptionInfo *info,
+ char *buf)
+{
+ int payload_offset = -1;
+
+ if (info->payloadOffset != -1) {
+ if (info->endian == LV_LITTLE_ENDIAN)
+ payload_offset = virReadBufInt32LE(buf + info->payloadOffset);
+ else
+ payload_offset = virReadBufInt32BE(buf + info->payloadOffset);
+ }
+
+ return payload_offset;
+}
+
+
/* Given a header in BUF with length LEN, as parsed from the storage file
* assuming it has the given FORMAT, populate information into META
* with information about the file and its backing store. Return format
@@ -967,6 +1001,8 @@ virStorageFileGetMetadataInternal(virStorageSourcePtr meta,
goto cleanup;
}
}
+ meta->encryption->payload_offset =
+ virStorageFileGetEncryptionPayloadOffset(&fileTypeInfo[meta->format].cryptInfo[i], buf);
}
}
}
@@ -3372,6 +3408,9 @@ virStorageSourceUpdateCapacity(virStorageSourcePtr src,
else
goto cleanup;
+ if (src->encryption && src->encryption->payload_offset != -1)
+ src->capacity -= src->encryption->payload_offset * 512;
+
ret = 0;
cleanup:
--
2.9.3
7 years, 12 months
[libvirt] [PATCH V3] util: Add more virsysfs functions for handling resctrl sysfs
by Eli Qiao
Extended /sys/fs/resctrl sysfs handling such as:
Read string/uint.
Write string.
Create/remove directory.
All these operations will be while we are enabled CAT feature later.
Signed-off-by: Eli Qiao <liyong.qiao(a)intel.com>
---
src/libvirt_private.syms | 9 +++
src/util/virsysfs.c | 143 +++++++++++++++++++++++++++++++++++++++++++++++
src/util/virsysfs.h | 26 +++++++++
src/util/virsysfspriv.h | 1 +
4 files changed, 179 insertions(+)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index b551cb8..f6644cb 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2620,17 +2620,26 @@ virVasprintfInternal;
# util/virsysfs.h
+virSysfsCreateResCtrlDir;
virSysfsGetCpuValueBitmap;
virSysfsGetCpuValueInt;
virSysfsGetCpuValueString;
virSysfsGetCpuValueUint;
virSysfsGetNodeValueBitmap;
virSysfsGetNodeValueString;
+virSysfsGetResctrlInfoString;
+virSysfsGetResctrlInfoUint;
+virSysfsGetResctrlPath;
+virSysfsGetResctrlString;
+virSysfsGetResctrlUint;
virSysfsGetSystemPath;
virSysfsGetValueBitmap;
virSysfsGetValueInt;
virSysfsGetValueString;
+virSysfsRemoveResCtrlDir;
+virSysfsSetResctrlPath;
virSysfsSetSystemPath;
+virSysfsWriteResctrlString;
# util/virsysinfo.h
diff --git a/src/util/virsysfs.c b/src/util/virsysfs.c
index 7a98b48..a17c391 100644
--- a/src/util/virsysfs.c
+++ b/src/util/virsysfs.c
@@ -19,6 +19,7 @@
*/
#include <config.h>
+#include <fcntl.h>
#include "internal.h"
@@ -36,8 +37,10 @@ VIR_LOG_INIT("util.sysfs");
#define VIR_SYSFS_VALUE_MAXLEN 8192
#define SYSFS_SYSTEM_PATH "/sys/devices/system"
+#define SYSFS_RESCTRL_PATH "/sys/fs/resctrl"
static const char *sysfs_system_path = SYSFS_SYSTEM_PATH;
+static const char *sysfs_resctrl_path = SYSFS_RESCTRL_PATH;
void virSysfsSetSystemPath(const char *path)
@@ -55,6 +58,20 @@ virSysfsGetSystemPath(void)
return sysfs_system_path;
}
+void virSysfsSetResctrlPath(const char *path)
+{
+ if (path)
+ sysfs_resctrl_path = path;
+ else
+ sysfs_resctrl_path = SYSFS_RESCTRL_PATH;
+}
+
+const char *
+virSysfsGetResctrlPath(void)
+{
+ return sysfs_resctrl_path;
+}
+
int
virSysfsGetValueInt(const char *file,
int *value)
@@ -227,3 +244,129 @@ virSysfsGetNodeValueBitmap(unsigned int node,
VIR_FREE(path);
return ret;
}
+
+int
+virSysfsGetResctrlString(const char* file,
+ char **value)
+{
+ char *path = NULL;
+ int ret = -1;
+ if (virAsprintf(&path, "%s/%s", sysfs_resctrl_path, file) < 0)
+ return -1;
+
+ if (virFileReadAll(path, VIR_SYSFS_VALUE_MAXLEN, value) < 0)
+ goto cleanup;
+
+ ret = 0;
+
+ cleanup:
+ VIR_FREE(path);
+ return ret;
+}
+
+int
+virSysfsGetResctrlUint(const char *file,
+ unsigned int *value)
+{
+ char *path = NULL;
+ int ret = -1;
+ if (virAsprintf(&path, "%s/%s", sysfs_resctrl_path, file) < 0)
+ return -1;
+
+ ret = virFileReadValueUint(path, value);
+
+ VIR_FREE(path);
+ return ret;
+}
+
+int
+virSysfsGetResctrlInfoString(const char* file,
+ char **value)
+{
+ char *path = NULL;
+ int ret = -1;
+ if (virAsprintf(&path, "%s/info/%s", sysfs_resctrl_path, file) < 0)
+ return -1;
+
+ if (virFileReadAll(path, VIR_SYSFS_VALUE_MAXLEN, value) < 0)
+ goto cleanup;
+
+ ret = 0;
+
+ cleanup:
+ VIR_FREE(path);
+ return ret;
+}
+
+int
+virSysfsGetResctrlInfoUint(const char *file,
+ unsigned int *value)
+{
+ char *path = NULL;
+ int ret;
+
+ if (virAsprintf(&path, "%s/info/%s", sysfs_resctrl_path, file) < 0)
+ return -1;
+
+ ret = virFileReadValueUint(path, value);
+
+ VIR_FREE(path);
+ return ret;
+}
+
+int
+virSysfsWriteResctrlString(const char *file,
+ const char *content)
+{
+ char *path = NULL;
+ int ret = -1;
+ int writefd;
+
+ if (virAsprintf(&path, "%s/%s", sysfs_resctrl_path, file) < 0)
+ return -1;
+
+ /* We can not use virFileWriteStr because resctrl requires oflag should be as
+ O_WRONLY | O_APPEND */
+ if ((writefd = open(path, O_WRONLY | O_APPEND, S_IRUSR | S_IWUSR)) < 0)
+ goto cleanup;
+
+ if (safewrite(writefd, content, strlen(content)) < 0)
+ goto cleanup;
+
+ ret = 0;
+
+ cleanup:
+ VIR_FORCE_CLOSE(writefd);
+ VIR_FREE(path);
+ return ret;
+}
+
+int
+virSysfsCreateResCtrlDir(const char *file)
+{
+ char *path = NULL;
+ int ret = -1;
+
+ if (virAsprintf(&path, "%s/%s", sysfs_resctrl_path, file) < 0)
+ return -1;
+
+ ret = virDirCreate(path, 0755, 0, 0, 0);
+
+ VIR_FREE(path);
+ return ret;
+}
+
+int
+virSysfsRemoveResCtrlDir(const char *file)
+{
+ char *path = NULL;
+ int ret = -1;
+
+ if (virAsprintf(&path, "%s/%s", sysfs_resctrl_path, file) < 0)
+ return -1;
+
+ ret = virFileDeleteTree(path);
+
+ VIR_FREE(path);
+ return ret;
+}
diff --git a/src/util/virsysfs.h b/src/util/virsysfs.h
index cd871ff..60ad444 100644
--- a/src/util/virsysfs.h
+++ b/src/util/virsysfs.h
@@ -25,6 +25,7 @@
# include "virbitmap.h"
const char * virSysfsGetSystemPath(void);
+const char * virSysfsGetResctrlPath(void);
int
virSysfsGetValueInt(const char *file,
@@ -67,4 +68,29 @@ virSysfsGetNodeValueBitmap(unsigned int cpu,
const char *file,
virBitmapPtr *value);
+int
+virSysfsGetResctrlString(const char* file,
+ char **value);
+
+int
+virSysfsGetResctrlUint(const char* file,
+ unsigned int *value);
+
+int
+virSysfsGetResctrlInfoString(const char* file,
+ char **value);
+
+int
+virSysfsGetResctrlInfoUint(const char *file,
+ unsigned int *value);
+
+int
+virSysfsWriteResctrlString(const char *file,
+ const char *content);
+
+int
+virSysfsCreateResCtrlDir(const char *file);
+
+int
+virSysfsRemoveResCtrlDir(const char *file);
#endif /* __VIR_SYSFS_H__*/
diff --git a/src/util/virsysfspriv.h b/src/util/virsysfspriv.h
index ae9f54a..bf36082 100644
--- a/src/util/virsysfspriv.h
+++ b/src/util/virsysfspriv.h
@@ -24,5 +24,6 @@
# include "virsysfs.h"
void virSysfsSetSystemPath(const char *path);
+void virSysfsSetResctrlPath(const char *path);
#endif /* __VIR_SYSFS_PRIV_H__*/
--
1.9.1
7 years, 12 months
[libvirt] Live attaching a disk to a VM fails with apparmor enabled
by Frank Schreuder
Hello,
I'm running libvirt 3.1.0 on a Debian 8 server. I installed apparmor and configured libvirt to use apparmor as security driver.
After booting a VM, virsh dumpxml shows an apparmor seclabel.
As soon as I try to attach a second disk to the VM, apparmor blocks this.
virsh attach-device test-vps /tmp/virshXmlDefinition
error: Failed to attach device from /tmp/virshXmlDefinition
error: operation failed: Could not open '/mnt/images/disk2.raw': Permission denied
Syslogs shows me the following:
Mar 22 17:45:20 vps0 kernel: [1136647.318314] audit: type=1400 audit(1490201120.577:30): apparmor="DENIED" operation="open" profile="libvirt-5747e4db-a3b7-fd69-ca89-00007b0bf859" name="/mnt/images/disk2.raw" pid=13453 comm="kvm" requested_mask="r" denied_mask="r" fsuid=996 ouid=33
Mar 22 17:45:20 vps0 kernel: [1136647.325155] audit: type=1400 audit(1490201120.577:31): apparmor="DENIED" operation="open" profile="libvirt-5747e4db-a3b7-fd69-ca89-00007b0bf859" name="/mnt/images/disk2.raw" pid=13453 comm="kvm" requested_mask="rw" denied_mask="rw" fsuid=996 ouid=33
Mar 22 17:45:20 vps0 libvirtd[10282]: 2017-03-22 16:45:20.596+0000: 10283: error : qemuMonitorTextAddDrive:1968 : operation failed: Could not open '/mnt/images/disk2.raw': Permission denied
In the VM specific apparmor file /etc/apparmor.d/libvirt/libvirt-5747e4db-a3b7-fd69-ca89-00007b0bf859.files I see:
"/mnt/images/disk1.raw" rw,
Which is my primary VM disk, I expected a virsh attach-device to append /mnt/images/disk2.raw to this file and reload/refresh the apparmor profile?
I'm not able to attach a live disk to a running VM with apparmor. Am I missing something? Or is this a bug/missing feature in libvirt?
Thanks,
Frank
7 years, 12 months