[libvirt] [PATCH] virkeycode: Allow ANSI_A
by Michal Privoznik
https://bugzilla.redhat.com/show_bug.cgi?id=1044806
Currently, sending the ANSI_A keycode from os_x codepage doesn't work as
it has a special value of 0x0. Our internal code handles that no
different to other not defined keycodes. Hence, in order to allow it we
must change all the undefined keycodes from 0 to -1 and adapt some code
too.
# virsh send-key guestname --codeset os_x ANSI_A
error: invalid keycode: 'ANSI_A'
# virsh send-key guestname --codeset os_x ANSI_B
# virsh send-key guestname --codeset os_x ANSI_C
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/util/virkeycode-mapgen.py | 4 ++--
src/util/virkeycode.c | 4 ++--
tools/virsh-domain.c | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/util/virkeycode-mapgen.py b/src/util/virkeycode-mapgen.py
index 22b21b4..8360bfe 100755
--- a/src/util/virkeycode-mapgen.py
+++ b/src/util/virkeycode-mapgen.py
@@ -86,12 +86,12 @@ for i in range(len(cols)):
if isname:
print "const char *virKeymapNames_" + name + "[] = {"
else:
- print "unsigned short virKeymapValues_" + name + "[] = {"
+ print "int virKeymapValues_" + name + "[] = {"
for entry in keycodes:
if isname:
print " " + quotestring(entry[i] or "NULL") + ","
else:
- print " " + (entry[i] or "0") + ","
+ print " " + (entry[i] or "-1") + ","
print "};\n"
diff --git a/src/util/virkeycode.c b/src/util/virkeycode.c
index 50594d6..7880a0a 100644
--- a/src/util/virkeycode.c
+++ b/src/util/virkeycode.c
@@ -50,7 +50,7 @@ static const char **virKeymapNames[] = {
};
verify(ARRAY_CARDINALITY(virKeymapNames) == VIR_KEYCODE_SET_LAST);
-static unsigned short *virKeymapValues[] = {
+static int *virKeymapValues[] = {
[VIR_KEYCODE_SET_LINUX] =
virKeymapValues_linux,
[VIR_KEYCODE_SET_XT] =
@@ -113,7 +113,7 @@ int virKeycodeValueTranslate(virKeycodeSet from_codeset,
{
size_t i;
- if (key_value <= 0)
+ if (key_value < 0)
return -1;
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 760dca5..b33b808 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -7091,7 +7091,7 @@ cmdSendKey(vshControl *ctl, const vshCmd *cmd)
}
if ((keycode = vshKeyCodeGetInt(opt->data)) <= 0) {
- if ((keycode = virKeycodeValueFromString(codeset, opt->data)) <= 0) {
+ if ((keycode = virKeycodeValueFromString(codeset, opt->data)) < 0) {
vshError(ctl, _("invalid keycode: '%s'"), opt->data);
goto cleanup;
}
--
1.8.5.1
10 years, 11 months
[libvirt] lvm storage pool destroy problem
by Umar Draz
Hi I am trying to stop the storage pool through php-libvirt api which is a
LVM volume group.
when I tried to stop it I got error
error: internal error Child process (/sbin/vgchange -aln mylvmgrp)
unexpected exit status 5: Can't deactivate volume group "mylvmgrp" with 4
open logical volume(s)
Then I tried throggh virsh command but the result remain same.
*root@kvm02:~# virsh pool-destroy vms*
error: Failed to destroy pool vms
error: internal error Child process (/sbin/vgchange -aln mylvmgrp)
unexpected exit status 5: Can't deactivate volume group "mylvmgrp" with 4
open logical volume(s)
The same error also occured if I use direct vgchange -aln on my kvm host,
but then I tried
*vgchange -aly mylvmgrp*
this time its worked
14 logical volume(s) in volume group "mylvmgrp" now active
1) Now would you please help me? is this libvirt issue? or LVM?
2) Is this possible virsh pool-destroy pool also run the vgchange -aly
instead of -aln
Br.
Umar
10 years, 11 months
[libvirt] [PATCH 2/3] Implementation deficiency in virInitctlSetRunLevel v2
by Reco
Implement fork & setns for lxcDomainShutdownFlags
---
src/lxc/lxc_driver.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index c499182..9d200b2 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -2619,6 +2619,50 @@ lxcDomainShutdownFlags(virDomainPtr dom,
goto cleanup;
}
+#ifdef HAVE_SETNS
+ if (flags == 0 || flags & VIR_DOMAIN_SHUTDOWN_INITCTL) {
+ int pid = -1;
+ int status = -1;
+ int mfd = -1;
+
+ if (virAsprintf(&vroot, "/proc/%llu/ns/mnt",
+ (unsigned long long)priv->initpid) < 0) {
+ goto cleanup;
+ }
+
+ if ((mfd = open(vroot, O_RDONLY)) < 0) {
+ virReportSystemError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
+ _("Kernel does not provide mount namespace"));
+ goto cleanup;
+ }
+
+ switch (pid = fork()) {
+ case 0:
+ if (setns(mfd, 0) == -1) {
+ exit(-1);
+ }
+ rc = virInitctlSetRunLevel(VIR_INITCTL_RUNLEVEL_POWEROFF, NULL);
+ exit(rc);
+ break;
+ case -1:
+ virReportSystemError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Fork failed"));
+ goto cleanup;
+ default:
+ if (waitpid(pid, &status, 0) < 0 || status < 0) {
+ virReportSystemError(errno,
+ _("Sending shutdown failed with status %i"),
+ status);
+ rc = 0;
+ } else {
+ rc = status;
+ }
+ close(mfd);
+ }
+ } else {
+ rc = 0;
+ }
+#else
if (virAsprintf(&vroot, "/proc/%llu/root",
(unsigned long long)priv->initpid) < 0)
goto cleanup;
@@ -2638,6 +2682,7 @@ lxcDomainShutdownFlags(virDomainPtr dom,
} else {
rc = 0;
}
+#endif
if (rc == 0 &&
(flags == 0 ||
--
1.7.10.4
10 years, 11 months
[libvirt] [PATCH] storage: fix bogus target in gluster volume xml
by Eric Blake
Commit 6cd60b6 was flat out broken - it tried to print into the
wrong variable. My testing was obviously too cursory (did the
name get a slash added?); valgrind would have caught the error.
Thankfully it didn't hit any release.
Reported by Peter Krempa.
* src/storage/storage_backend_gluster.c
(virStorageBackendGlusterRefreshVol): Fix bogus code.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
src/storage/storage_backend_gluster.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/storage/storage_backend_gluster.c b/src/storage/storage_backend_gluster.c
index 622526b..9aa692e 100644
--- a/src/storage/storage_backend_gluster.c
+++ b/src/storage/storage_backend_gluster.c
@@ -227,7 +227,7 @@ virStorageBackendGlusterRefreshVol(virStorageBackendGlusterStatePtr state,
goto cleanup;
tmp = state->uri->path;
- if (virAsprintf(&vol->key, "%s%s", state->uri->path, name) < 0) {
+ if (virAsprintf(&state->uri->path, "/%s", vol->key) < 0) {
state->uri->path = tmp;
goto cleanup;
}
--
1.8.4.2
10 years, 11 months
[libvirt] [PATCH 0/5] Fill qemucapabilitiesdata with some data
by Michal Privoznik
The actual patches are accessible at:
git://gitorious.org/libvirt/michal-staging.git
branch test_qemu_capabilities_data
I'm not sending the actual patches as it's big junk of JSON qemu replies. The
patches has from 35KiB to 59KiB. I don't want to overload the list.
Michal Privoznik (5):
qemucapabilitiesdata: Add qemu-1.2.2 data
qemucapabilitiesdata: Add qemu-1.3.1 data
qemucapabilitiesdata: Add qemu-1.4.2 data
qemucapabilitiesdata: Add qemu-1.6.0 data
qemucapabilitiesdata: Add qemu-1.6.50 data
tests/qemucapabilitiesdata/caps_1.2.2-1.caps | 114 +
tests/qemucapabilitiesdata/caps_1.2.2-1.replies | 1543 +++++++++++++
tests/qemucapabilitiesdata/caps_1.3.1-1.caps | 128 ++
tests/qemucapabilitiesdata/caps_1.3.1-1.replies | 1715 +++++++++++++++
tests/qemucapabilitiesdata/caps_1.4.2-1.caps | 129 ++
tests/qemucapabilitiesdata/caps_1.4.2-1.replies | 1765 +++++++++++++++
tests/qemucapabilitiesdata/caps_1.6.0-1.caps | 137 ++
tests/qemucapabilitiesdata/caps_1.6.0-1.replies | 2499 ++++++++++++++++++++++
tests/qemucapabilitiesdata/caps_1.6.50-1.caps | 136 ++
tests/qemucapabilitiesdata/caps_1.6.50-1.replies | 2476 +++++++++++++++++++++
tests/qemucapabilitiestest.c | 5 +
11 files changed, 10647 insertions(+)
create mode 100644 tests/qemucapabilitiesdata/caps_1.2.2-1.caps
create mode 100644 tests/qemucapabilitiesdata/caps_1.2.2-1.replies
create mode 100644 tests/qemucapabilitiesdata/caps_1.3.1-1.caps
create mode 100644 tests/qemucapabilitiesdata/caps_1.3.1-1.replies
create mode 100644 tests/qemucapabilitiesdata/caps_1.4.2-1.caps
create mode 100644 tests/qemucapabilitiesdata/caps_1.4.2-1.replies
create mode 100644 tests/qemucapabilitiesdata/caps_1.6.0-1.caps
create mode 100644 tests/qemucapabilitiesdata/caps_1.6.0-1.replies
create mode 100644 tests/qemucapabilitiesdata/caps_1.6.50-1.caps
create mode 100644 tests/qemucapabilitiesdata/caps_1.6.50-1.replies
--
1.8.1.5
10 years, 11 months
[libvirt] [PATCH 3/3] Implementation deficiency in virInitctlSetRunLevel v2
by Reco
Implement fork & setns for lxcDomainShutdownFlags
---
src/lxc/lxc_driver.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 9d200b2..1227736 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -2744,6 +2744,50 @@ lxcDomainReboot(virDomainPtr dom,
goto cleanup;
}
+#ifdef HAVE_SETNS
+ if (flags == 0 || flags & VIR_DOMAIN_REBOOT_INITCTL) {
+ int pid = -1;
+ int status = -1;
+ int mfd = -1;
+
+ if (virAsprintf(&vroot, "/proc/%llu/ns/mnt",
+ (unsigned long long)priv->initpid) < 0) {
+ goto cleanup;
+ }
+
+ if ((mfd = open(vroot, O_RDONLY)) < 0) {
+ virReportSystemError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
+ _("Kernel does not provide mount namespace"));
+ goto cleanup;
+ }
+
+ switch (pid = fork()) {
+ case 0:
+ if (setns(mfd, 0) == -1) {
+ exit(-1);
+ }
+ rc = virInitctlSetRunLevel(VIR_INITCTL_RUNLEVEL_REBOOT, NULL);
+ exit(rc);
+ break;
+ case -1:
+ virReportSystemError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Fork failed"));
+ goto cleanup;
+ default:
+ if (waitpid(pid, &status, 0) < 0 || status < 0) {
+ virReportSystemError(errno,
+ _("Sending reboot failed with status %i"),
+ status);
+ rc = 0;
+ } else {
+ rc = status;
+ }
+ close(mfd);
+ }
+ } else {
+ rc = 0;
+ }
+#else
if (virAsprintf(&vroot, "/proc/%llu/root",
(unsigned long long)priv->initpid) < 0)
goto cleanup;
@@ -2763,6 +2807,7 @@ lxcDomainReboot(virDomainPtr dom,
} else {
rc = 0;
}
+#endif
if (rc == 0 &&
(flags == 0 ||
--
1.7.10.4
10 years, 11 months
[libvirt] [PATCH 1/3] Implementation deficiency in virInitctlSetRunLevel v2
by Reco
Hello, list.
Refuse following symlinks in virInitctlSetRunLevel.
A reasonable fallback for the next two patches, which apply fork-setns
technique recommended on this list.
---
src/util/virinitctl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/util/virinitctl.c b/src/util/virinitctl.c
index 64bc23a..5cea992 100644
--- a/src/util/virinitctl.c
+++ b/src/util/virinitctl.c
@@ -139,7 +139,7 @@ int virInitctlSetRunLevel(virInitctlRunLevel level,
return -1;
}
- if ((fd = open(path, O_WRONLY|O_NONBLOCK|O_CLOEXEC|O_NOCTTY)) < 0)
{
+ if ((fd = open(path, O_WRONLY|O_NONBLOCK|O_CLOEXEC|O_NOCTTY|O_NOFOLLOW)) < 0) {
if (errno == ENOENT) {
ret = 0;
goto cleanup;
--
1.7.10.4
10 years, 11 months
[libvirt] [PATCH RFC 00/27] Native external gluster snapshots
by Peter Krempa
This series refactors and fixes stuff needed to support snapshots
on gluster-backed vm's.
The series is marked as RFC as docs for some of the changes are missing
and I'd like to start code review while I'll figure out the docs.
Peter Krempa (27):
DO NOT APPLY UPSTREAM: Reproducer for disk snapshot crash
qemu: snapshot: Avoid libvirtd crash when qemu crashes while
snapshotting
Revert "DO NOT APPLY UPSTREAM: Reproducer for disk snapshot crash"
Revert "storage: fix omitted slash in gluster volume URI"
storage: gluster: Properly fix missing slashes in volume paths
snapshot: schema: Split out snapshot disk driver definition
snapshot: Add support for specifying snapshot disk backing type
snapshot: Test snapshot disk type specification
storage: Add gluster pool filter and fix virsh pool listing
storage: Avoid forward declaration of virStorageVolDelete
storage: fs: Fix comment for virStorageBackendFileSystemDelete
storage: Support deletion of volumes on gluster pools
storage: lvm: Avoid forward decl of virStorageBackendLogicalDeleteVol
storage: LVM: Separate creating of the volume from building
storage: disk: Separate creating of the volume from building
storage: RBD: Separate creating of the volume from building
storage: Sheepdog: Separate creating of the volume from building
storage: Introduce internal pool support
storage: Add new argument for createVol backend API
storage: gluster: Introduce dummy functions for creating a volume
storage: Improve error message when a storage backend is missing
maint: Fix messy include of libvirt_internal.h
storage: Add internal API to create temporary storage pools and vols
storage: Implement ephemeral storage APIs for local disk volumes
storage: gluster: Support conversion of gluster volumes to temp
volumes
qemu: snapshot: Switch snapshot file deletion to the new storage API
qemu: snapshot: Add support for external active snapshots on gluster
docs/hvsupport.pl | 3 +
docs/schemas/domainsnapshot.rng | 94 +++-
include/libvirt/libvirt.h.in | 1 +
src/Makefile.am | 3 +-
src/check-aclrules.pl | 3 +
src/check-drivername.pl | 1 +
src/conf/snapshot_conf.c | 25 +-
src/conf/snapshot_conf.h | 15 +-
src/conf/storage_conf.c | 7 +-
src/conf/storage_conf.h | 1 +
src/driver.h | 14 +
src/internal.h | 2 -
src/libvirt_internal.c | 71 +++
src/libvirt_internal.h | 22 +
src/libvirt_private.syms | 3 +
src/libxl/libxl_conf.h | 1 +
src/lxc/lxc_conf.h | 1 +
src/qemu/qemu_command.c | 2 +-
src/qemu/qemu_command.h | 9 +
src/qemu/qemu_driver.c | 274 +++++++++--
src/storage/storage_backend.c | 3 +-
src/storage/storage_backend.h | 2 +-
src/storage/storage_backend_disk.c | 47 +-
src/storage/storage_backend_fs.c | 36 +-
src/storage/storage_backend_gluster.c | 139 +++++-
src/storage/storage_backend_logical.c | 129 ++---
src/storage/storage_backend_rbd.c | 42 +-
src/storage/storage_backend_sheepdog.c | 32 +-
src/storage/storage_driver.c | 597 +++++++++++++++++++----
src/uml/uml_conf.h | 1 +
tests/domainsnapshotxml2xmlin/disk_snapshot.xml | 18 +
tests/domainsnapshotxml2xmlout/disk_snapshot.xml | 18 +
tools/virsh-pool.c | 9 +-
33 files changed, 1341 insertions(+), 284 deletions(-)
create mode 100644 src/libvirt_internal.c
--
1.8.5.1
10 years, 11 months
[libvirt] [PATCH] add --nocow option to vol-create and vol-clone
by Chunyan Liu
Btrfs has terrible performance when hosting VM images, even more when the guest
in those VM are also using btrfs as file system. One way to mitigate this bad
performance is to turn off COW attributes on VM files (since having copy on
write for this kind of data is not useful).
According to 'chattr' manpage, NOCOW could be set to new or empty file only on
btrfs, so this patch tries to add a --nocow option to vol-create functions and
vol-clone function, so that users could have a chance to set NOCOW to a new
volume if that happens to create on a btrfs like file system.
Signed-off-by: Chunyan Liu <cyliu(a)suse.com>
---
include/libvirt/libvirt.h.in | 1 +
src/storage/storage_backend.c | 2 +-
src/storage/storage_backend_fs.c | 49 ++++++++++++++++++++++++++++++++++++-
src/storage/storage_driver.c | 6 +++-
tools/virsh-volume.c | 26 ++++++++++++++++++-
5 files changed, 77 insertions(+), 7 deletions(-)
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 5aad75c..0761ba6 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -3151,6 +3151,7 @@ const char* virStorageVolGetKey (virStorageVolPtr vol);
typedef enum {
VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA = 1 << 0,
+ VIR_STORAGE_VOL_CREATE_NOCOW = 1 << 1,
} virStorageVolCreateFlags;
virStorageVolPtr virStorageVolCreateXML (virStoragePoolPtr pool,
diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
index 57c1728..8ce7e99 100644
--- a/src/storage/storage_backend.c
+++ b/src/storage/storage_backend.c
@@ -423,7 +423,7 @@ virStorageBackendCreateRaw(virConnectPtr conn ATTRIBUTE_UNUSED,
operation_flags |= VIR_FILE_OPEN_FORK;
if ((fd = virFileOpenAs(vol->target.path,
- O_RDWR | O_CREAT | O_EXCL,
+ O_RDWR | O_CREAT,
vol->target.perms.mode,
vol->target.perms.uid,
vol->target.perms.gid,
diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c
index 11cf2df..d60b64c 100644
--- a/src/storage/storage_backend_fs.c
+++ b/src/storage/storage_backend_fs.c
@@ -51,6 +51,13 @@
#include "virfile.h"
#include "virlog.h"
#include "virstring.h"
+#ifdef __linux__
+# include <sys/ioctl.h>
+# include <linux/fs.h>
+#ifndef FS_NOCOW_FL
+#define FS_NOCOW_FL 0x00800000 /* Do not cow file */
+#endif
+#endif
#define VIR_FROM_THIS VIR_FROM_STORAGE
@@ -1090,6 +1097,42 @@ _virStorageBackendFileSystemVolBuild(virConnectPtr conn,
return -1;
}
+ if (flags & VIR_STORAGE_VOL_CREATE_NOCOW) {
+#ifdef __linux__
+ /* create an empty file and set nocow flag.
+ * This could optimize performance on file system like btrfs.
+ */
+ int attr, fd;
+ int operation_flags = VIR_FILE_OPEN_FORCE_MODE | VIR_FILE_OPEN_FORCE_OWNER;
+ if (pool->def->type == VIR_STORAGE_POOL_NETFS)
+ operation_flags |= VIR_FILE_OPEN_FORK;
+
+ if ((fd = virFileOpenAs(vol->target.path,
+ O_RDWR | O_CREAT | O_EXCL | O_LARGEFILE,
+ vol->target.perms.mode,
+ vol->target.perms.uid,
+ vol->target.perms.gid,
+ operation_flags)) < 0) {
+ virReportSystemError(-fd,
+ _("Failed to create file '%s'"),
+ vol->target.path);
+ return -1;
+ }
+
+ /* This is an optimisation. The FS_IOC_SETFLAGS ioctl return value will
+ * be ignored since any failure of this operation should not block the
+ * left work.
+ */
+ if (ioctl(fd, FS_IOC_GETFLAGS, &attr) == 0) {
+ attr |= FS_NOCOW_FL;
+ ioctl(fd, FS_IOC_SETFLAGS, &attr);
+ }
+
+ VIR_FORCE_CLOSE(fd);
+#endif
+ flags &= ~VIR_STORAGE_VOL_CREATE_NOCOW;
+ }
+
if (create_func(conn, pool, vol, inputvol, flags) < 0)
return -1;
return 0;
@@ -1106,7 +1149,8 @@ virStorageBackendFileSystemVolBuild(virConnectPtr conn,
virStorageVolDefPtr vol,
unsigned int flags)
{
- virCheckFlags(VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA, -1);
+ virCheckFlags(VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA |
+ VIR_STORAGE_VOL_CREATE_NOCOW, -1);
return _virStorageBackendFileSystemVolBuild(conn, pool, vol, NULL, flags);
}
@@ -1121,7 +1165,8 @@ virStorageBackendFileSystemVolBuildFrom(virConnectPtr conn,
virStorageVolDefPtr inputvol,
unsigned int flags)
{
- virCheckFlags(VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA, -1);
+ virCheckFlags(VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA |
+ VIR_STORAGE_VOL_CREATE_NOCOW, -1);
return _virStorageBackendFileSystemVolBuild(conn, pool, vol, inputvol, flags);
}
diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index 3b4715a..2aef1a7 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -1509,7 +1509,8 @@ storageVolCreateXML(virStoragePoolPtr obj,
virStorageVolPtr ret = NULL, volobj = NULL;
virStorageVolDefPtr buildvoldef = NULL;
- virCheckFlags(VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA, NULL);
+ virCheckFlags(VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA |
+ VIR_STORAGE_VOL_CREATE_NOCOW, NULL);
storageDriverLock(driver);
pool = virStoragePoolObjFindByUUID(&driver->pools, obj->uuid);
@@ -1641,7 +1642,8 @@ storageVolCreateXMLFrom(virStoragePoolPtr obj,
unsigned long long allocation;
int buildret;
- virCheckFlags(VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA, NULL);
+ virCheckFlags(VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA |
+ VIR_STORAGE_VOL_CREATE_NOCOW, NULL);
storageDriverLock(driver);
pool = virStoragePoolObjFindByUUID(&driver->pools, obj->uuid);
diff --git a/tools/virsh-volume.c b/tools/virsh-volume.c
index 22b10d5..bfbcc1f 100644
--- a/tools/virsh-volume.c
+++ b/tools/virsh-volume.c
@@ -151,6 +151,10 @@ static const vshCmdOptDef opts_vol_create_as[] = {
.type = VSH_OT_BOOL,
.help = N_("preallocate metadata (for qcow2 instead of full allocation)")
},
+ {.name = "nocow",
+ .type = VSH_OT_BOOL,
+ .help = N_("turn off copy-on-write (for file on fs like btrfs)")
+ },
{.name = NULL}
};
@@ -177,6 +181,8 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd)
if (vshCommandOptBool(cmd, "prealloc-metadata"))
flags |= VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA;
+ if (vshCommandOptBool(cmd, "nocow"))
+ flags |= VIR_STORAGE_VOL_CREATE_NOCOW;
if (!(pool = vshCommandOptPool(ctl, cmd, "pool", NULL)))
return false;
@@ -330,6 +336,10 @@ static const vshCmdOptDef opts_vol_create[] = {
.type = VSH_OT_BOOL,
.help = N_("preallocate metadata (for qcow2 instead of full allocation)")
},
+ {.name = "nocow",
+ .type = VSH_OT_BOOL,
+ .help = N_("turn off copy-on-write (for file on fs like btrfs)")
+ },
{.name = NULL}
};
@@ -345,6 +355,8 @@ cmdVolCreate(vshControl *ctl, const vshCmd *cmd)
if (vshCommandOptBool(cmd, "prealloc-metadata"))
flags |= VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA;
+ if (vshCommandOptBool(cmd, "nocow"))
+ flags |= VIR_STORAGE_VOL_CREATE_NOCOW;
if (!(pool = vshCommandOptPool(ctl, cmd, "pool", NULL)))
return false;
@@ -408,6 +420,10 @@ static const vshCmdOptDef opts_vol_create_from[] = {
.type = VSH_OT_BOOL,
.help = N_("preallocate metadata (for qcow2 instead of full allocation)")
},
+ {.name = "nocow",
+ .type = VSH_OT_BOOL,
+ .help = N_("turn off copy-on-write (for file on fs like btrfs)")
+ },
{.name = NULL}
};
@@ -426,7 +442,8 @@ cmdVolCreateFrom(vshControl *ctl, const vshCmd *cmd)
if (vshCommandOptBool(cmd, "prealloc-metadata"))
flags |= VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA;
-
+ if (vshCommandOptBool(cmd, "nocow"))
+ flags |= VIR_STORAGE_VOL_CREATE_NOCOW;
if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0)
goto cleanup;
@@ -521,6 +538,10 @@ static const vshCmdOptDef opts_vol_clone[] = {
.type = VSH_OT_BOOL,
.help = N_("preallocate metadata (for qcow2 instead of full allocation)")
},
+ {.name = "nocow",
+ .type = VSH_OT_BOOL,
+ .help = N_("turn off copy-on-write (for file on fs like btrfs)")
+ },
{.name = NULL}
};
@@ -540,7 +561,8 @@ cmdVolClone(vshControl *ctl, const vshCmd *cmd)
if (vshCommandOptBool(cmd, "prealloc-metadata"))
flags |= VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA;
-
+ if (vshCommandOptBool(cmd, "nocow"))
+ flags |= VIR_STORAGE_VOL_CREATE_NOCOW;
origpool = virStoragePoolLookupByVolume(origvol);
if (!origpool) {
vshError(ctl, "%s", _("failed to get parent pool"));
--
1.6.0.2
10 years, 11 months
[libvirt] [v8 0/6]Write separate module for hostdev passthrough
by Chunyan Liu
These patches implements a separate module for hostdev passthrough so that it
could be shared by different drivers and can maintain a global state of a host
device.
patch 1/6: extract hostdev passthrough function from qemu_hostdev.c and make it
reusable by multiple drivers.
patch 2/6: add a unit test for hostdev common library.
patch 3/6: switch qemu driver to use the common library instead of its own
hostdev passthrough APIs.
patch 4/6: switch lxc driver to use the common library instead of its own
hostdev passthrough APIs.
patch 5/6: add a hostdev pci backend type for xen usage.
patch 6/6: add pci passthrough to libxl driver.
---
Changes:
* fix v7 comments
* reorganize order of patches
* rebase to latest source code
Chunyan Liu (6):
add hostdev passthrough common library
add a unit test for hostdev common library
change qemu driver to use hostdev common library
change lxc driver to use hostdev common library
add hostdev pci backend type for xen
add pci passthrough to libxl driver
docs/schemas/domaincommon.rng | 1 +
po/POTFILES.in | 3 +-
src/Makefile.am | 3 +-
src/conf/domain_conf.c | 3 +-
src/conf/domain_conf.h | 1 +
src/libvirt_private.syms | 21 +
src/libxl/libxl_conf.c | 63 +
src/libxl/libxl_conf.h | 4 +
src/libxl/libxl_domain.c | 9 +
src/libxl/libxl_driver.c | 448 +++++-
src/lxc/lxc_conf.h | 4 -
src/lxc/lxc_driver.c | 47 +-
src/lxc/lxc_hostdev.c | 413 -----
src/lxc/lxc_hostdev.h | 43 -
src/lxc/lxc_process.c | 24 +-
src/qemu/qemu_command.c | 4 +-
src/qemu/qemu_conf.h | 9 +-
src/qemu/qemu_domain.c | 22 +
src/qemu/qemu_driver.c | 81 +-
src/qemu/qemu_hostdev.c | 1454 -----------------
src/qemu/qemu_hostdev.h | 76 -
src/qemu/qemu_hotplug.c | 136 +-
src/qemu/qemu_process.c | 40 +-
src/util/virhostdev.c | 1703 ++++++++++++++++++++
src/util/virhostdev.h | 134 ++
src/util/virpci.c | 30 +-
src/util/virpci.h | 9 +-
src/util/virscsi.c | 28 +-
src/util/virscsi.h | 8 +-
src/util/virusb.c | 29 +-
src/util/virusb.h | 8 +-
tests/Makefile.am | 5 +
.../qemuxml2argv-hostdev-pci-address.xml | 1 +
.../qemuxml2argvdata/qemuxml2argv-net-hostdev.xml | 1 +
tests/qemuxml2argvdata/qemuxml2argv-pci-rom.xml | 2 +
tests/virhostdevtest.c | 481 ++++++
tests/virpcimock.c | 45 +-
37 files changed, 3181 insertions(+), 2212 deletions(-)
delete mode 100644 src/lxc/lxc_hostdev.c
delete mode 100644 src/lxc/lxc_hostdev.h
delete mode 100644 src/qemu/qemu_hostdev.c
delete mode 100644 src/qemu/qemu_hostdev.h
create mode 100644 src/util/virhostdev.c
create mode 100644 src/util/virhostdev.h
create mode 100644 tests/virhostdevtest.c
10 years, 11 months