Re: [libvirt] [PATCH] util: generate correct macvtap name

2016-03-29 Thread Shanzhi Yu



On 03/29/2016 12:23 AM, Laine Stump wrote:

On 03/28/2016 10:42 AM, Laine Stump wrote:

On 03/28/2016 06:43 AM, Shanzhi Yu wrote:

in commit 370608b, bitmap of in-used macvtap devices was introduced.
if there is already macvtap device created not by libvirt,
virNetDevMacVLanCreateWithVPortProfile will failed after try
MACVLAN_MAX_ID times call virNetDevMacVLanReleaseID

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1321546


NACK.

This is a bonafide bug, but not the right fix. Your patch would go
back and pick up the unused "macvtap0" name rather than trying
macvtap2, but once macvtap0 was in use, the next call (for yet another
macvtap device) would attempt to use macvtap2 (since macvtap0 and
macvtap1 were in use) and would then end up looping in the same manner
as it did without your patch (MACVLAN_MAX_ID times == 8191) and then
still reporting a failure.


Sigh. The above is incorrect, as I was trying to trace through the code
in my mind after mentally applying the patch, rather than actually
trying it.



Thanks for your explanations, actually your fix is really what I want, I 
should go through virNetDevMacVLanReserveID carefully.




As a matter of fact, the reality is worse than the above description.
With this patch the device name is constructed by using the id number
that we *want* to reserve rather than the one that we actually do
reserve, but the bug in virNetDevMacVLanReserveID() is still there, so
in fact what will happen is that the newly patched loop will

  1) format the name to use as "macvtap0"
  2) ask for macvtap0
  3) get back macvtap2, but ignore that
  4) try/fail to create macvtap0
  5) *NOT* release the id that it just allocated (which was macvtap2)
  6) loop again
  7) format "macvtap2"
  8) ask for macvtap2
  9) get back macvtap3, but ignore that
10) try/fail to create macvtap2
11) *NOT release the id that was just reserved (macvtap3)
12) loop again
13) format macvtap3
14) ask for macvtap3
15) get back macvtap4 (even though nobody is using macvtap3,
 we reserved it in the last iteration, didn't use it,
 and didn't free it!)
16) try/succeed to create macvtap3

So at this point, we have reserved macvtap2, macvtap3, and macvtap4,
even though libvirt is only using macvtap3 (and something outside of
libvirt is using macvtap2). The next time someone wants a macvtap
device, we'll again start out at 0, get back 5, try/fail to create 0,
ask for 1, get back 6, try/fail to create 1, ask for 2, get back 7,
try/fail to create 2, ask for 3, get back 8, try/fail to create 3, ask
for 4, get back 9, and finally succeed with macvtap4. So *now* we've
reserved all names up through macvtap9, but are only using macvtap0,
macvtap1 (these from previous), macvtap3, and macvtap4. We'll continue
like this, reserving n-1 extra names for each new macvtap device "n",
thus running out much more quickly.

Anyway, that's probably much more analysis than necessary. The main
points (in addition to the fact that it doesn't fix the root cause) are:

a) it creates the macvtap name based on the desired id# rather than the
one that was actually reserved
b) it never frees the id's that it ends up not using because the create
failed.




The proper fix is to call virBitmapNextClearBit() (inside
virNetDevMacVLanReserveID()) with the most recently failed id (or -1)
rather than with 0. This is what I've done in the following patch:

https://www.redhat.com/archives/libvir-list/2016-March/msg01286.html




Signed-off-by: Shanzhi Yu <s...@redhat.com>
---
  src/util/virnetdevmacvlan.c | 16 +---
  1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/src/util/virnetdevmacvlan.c b/src/util/virnetdevmacvlan.c
index 2409113..973363e 100644
--- a/src/util/virnetdevmacvlan.c
+++ b/src/util/virnetdevmacvlan.c
@@ -988,7 +988,8 @@ virNetDevMacVLanCreateWithVPortProfile(const char
*ifnameRequested,
  MACVTAP_NAME_PREFIX : MACVLAN_NAME_PREFIX;
  const char *pattern = (flags &
VIR_NETDEV_MACVLAN_CREATE_WITH_TAP) ?
  MACVTAP_NAME_PATTERN : MACVLAN_NAME_PATTERN;
-int rc, reservedID = -1;
+int rc = -1;
+int reservedID = 0;
  char ifname[IFNAMSIZ];
  int retries, do_retry = 0;
  uint32_t macvtapMode;
@@ -1072,16 +1073,17 @@ virNetDevMacVLanCreateWithVPortProfile(const
char *ifnameRequested,
  retries = MACVLAN_MAX_ID;
  while (!ifnameCreated && retries) {
  virMutexLock();
-reservedID = virNetDevMacVLanReserveID(reservedID, flags,
false, true);
-if (reservedID < 0) {
-virMutexUnlock();
-return -1;
-}
  snprintf(ifname, sizeof(ifname), pattern, reservedID);
  rc = virNetDevMacVLanCreate(ifname, type, macaddress, linkdev,
  macvtapMode, _retry);
  if (rc < 0) {
-virNetDevMacVLanReleaseID(reservedID, flags);
+reservedID++;
+reser

[libvirt] [PATCH] util: generate correct macvtap name

2016-03-28 Thread Shanzhi Yu
in commit 370608b, bitmap of in-used macvtap devices was introduced.
if there is already macvtap device created not by libvirt,
virNetDevMacVLanCreateWithVPortProfile will failed after try
MACVLAN_MAX_ID times call virNetDevMacVLanReleaseID

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1321546

Signed-off-by: Shanzhi Yu <s...@redhat.com>
---
 src/util/virnetdevmacvlan.c | 16 +---
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/src/util/virnetdevmacvlan.c b/src/util/virnetdevmacvlan.c
index 2409113..973363e 100644
--- a/src/util/virnetdevmacvlan.c
+++ b/src/util/virnetdevmacvlan.c
@@ -988,7 +988,8 @@ virNetDevMacVLanCreateWithVPortProfile(const char 
*ifnameRequested,
 MACVTAP_NAME_PREFIX : MACVLAN_NAME_PREFIX;
 const char *pattern = (flags & VIR_NETDEV_MACVLAN_CREATE_WITH_TAP) ?
 MACVTAP_NAME_PATTERN : MACVLAN_NAME_PATTERN;
-int rc, reservedID = -1;
+int rc = -1;
+int reservedID = 0;
 char ifname[IFNAMSIZ];
 int retries, do_retry = 0;
 uint32_t macvtapMode;
@@ -1072,16 +1073,17 @@ virNetDevMacVLanCreateWithVPortProfile(const char 
*ifnameRequested,
 retries = MACVLAN_MAX_ID;
 while (!ifnameCreated && retries) {
 virMutexLock();
-reservedID = virNetDevMacVLanReserveID(reservedID, flags, false, true);
-if (reservedID < 0) {
-virMutexUnlock();
-return -1;
-}
 snprintf(ifname, sizeof(ifname), pattern, reservedID);
 rc = virNetDevMacVLanCreate(ifname, type, macaddress, linkdev,
 macvtapMode, _retry);
 if (rc < 0) {
-virNetDevMacVLanReleaseID(reservedID, flags);
+reservedID++;
+reservedID = virNetDevMacVLanReserveID(reservedID, flags, false, 
true);
+if (reservedID < 0) {
+virMutexUnlock();
+return -1;
+}
+
 virMutexUnlock();
 if (!do_retry)
 return -1;
-- 
1.8.3.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] rbd: use unsigned long long instead of uint64_t

2016-03-28 Thread Shanzhi Yu
Fix below error:
storage/storage_backend_rbd.c: In function 'virStorageBackendRBDSetAllocation':
storage/storage_backend_rbd.c:337:5: error: format '%llu' expects argument of 
type 'long long unsigned int', but argument 8 has type 'uint64_t' 
[-Werror=format=]
VIR_DEBUG("Found %llu bytes allocated for RBD image %s",

Signed-off-by: Shanzhi Yu <s...@redhat.com>
---
 src/storage/storage_backend_rbd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/storage/storage_backend_rbd.c 
b/src/storage/storage_backend_rbd.c
index c9b47e2..dec0905 100644
--- a/src/storage/storage_backend_rbd.c
+++ b/src/storage/storage_backend_rbd.c
@@ -324,7 +324,7 @@ virStorageBackendRBDSetAllocation(virStorageVolDefPtr vol,
   rbd_image_info_t *info)
 {
 int r, ret = -1;
-uint64_t allocation = 0;
+unsigned long long allocation = 0;
 
 if ((r = rbd_diff_iterate2(image, NULL, 0, info->size, 0, 1,
,
-- 
1.8.3.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] qemu: improve the error when try to undefine transient network

2016-03-06 Thread Shanzhi Yu
Signed-off-by: Shanzhi Yu <s...@redhat.com>
---
 src/network/bridge_driver.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 7ab9e29..b62fdff 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -3222,6 +3222,12 @@ networkUndefine(virNetworkPtr net)
 if (virNetworkObjIsActive(network))
 active = true;
 
+if (!network->persistent) {
+virReportError(VIR_ERR_OPERATION_INVALID,
+   "%s", _("can't undefine transient network"));
+goto cleanup;
+}
+
 /* remove autostart link */
 if (virNetworkDeleteConfig(driver->networkConfigDir,
driver->networkAutostartDir,
-- 
1.8.3.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] qemu: forbid renaming domain which has managedsave file

2016-03-03 Thread Shanzhi Yu
after rename a domain which has managedsave file, the new name domain
can't boot up from the state it saved, and the managedsave file will
exist with the original name.

Signed-off-by: Shanzhi Yu <s...@redhat.com>
---
 src/qemu/qemu_driver.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 4bd4071..036a367 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -2,6 +2,12 @@ static int qemuDomainRename(virDomainPtr dom,
 goto endjob;
 }
 
+if (vm->hasManagedSave) {
+virReportError(VIR_ERR_OPERATION_INVALID, "%s",
+   _("can't rename a domain has managedsave file"));
+goto endjob;
+}
+
 if (virDomainObjListRename(driver->domains, vm, new_name, flags,
qemuDomainRenameCallback, driver) < 0)
 goto endjob;
-- 
2.5.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] qemu: enalbe hotplugging of macvtap device with multiqueue

2016-02-25 Thread Shanzhi Yu
in commit 81a110, multiqueue for macvtap is enabled but forget
to support hotplugging enabled

Signed-off-by: Shanzhi Yu <s...@redhat.com>
---
 src/qemu/qemu_hotplug.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index dc76268..b580283 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -892,10 +892,11 @@ int qemuDomainAttachNetDevice(virConnectPtr conn,
 goto cleanup;
 }
 
-/* Currently nothing besides TAP devices supports multiqueue. */
+/* Currently only TAP/macvtap devices supports multiqueue. */
 if (net->driver.virtio.queues > 0 &&
 !(actualType == VIR_DOMAIN_NET_TYPE_NETWORK ||
-  actualType == VIR_DOMAIN_NET_TYPE_BRIDGE)) {
+  actualType == VIR_DOMAIN_NET_TYPE_BRIDGE ||
+  actualType == VIR_DOMAIN_NET_TYPE_DIRECT)) {
 virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Multiqueue network is not supported for: %s"),
virDomainNetTypeToString(actualType));
-- 
1.8.3.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH v2] security_selinux: Fix crash in virSecuritySELinuxRestoreFileLabel

2016-01-21 Thread Shanzhi Yu
virSecuritySELinuxRestoreFileLabel should never be called with NULL path
add check before call this function in case of causeing libvirtd crash

https://bugzilla.redhat.com/show_bug.cgi?id=1300532
Signed-off-by: Shanzhi Yu <s...@redhat.com>
---
 src/security/security_selinux.c | 25 +
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c
index 9e98635..77e55a3 100644
--- a/src/security/security_selinux.c
+++ b/src/security/security_selinux.c
@@ -1098,7 +1098,8 @@ virSecuritySELinuxRestoreInputLabel(virSecurityManagerPtr 
mgr,
 
 switch ((virDomainInputType) input->type) {
 case VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH:
-rc = virSecuritySELinuxRestoreFileLabel(mgr, input->source.evdev);
+if (input->source.evdev)
+rc = virSecuritySELinuxRestoreFileLabel(mgr, input->source.evdev);
 break;
 
 case VIR_DOMAIN_INPUT_TYPE_MOUSE:
@@ -1171,7 +1172,9 @@ 
virSecuritySELinuxRestoreTPMFileLabelInt(virSecurityManagerPtr mgr,
 switch (tpm->type) {
 case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH:
 tpmdev = tpm->data.passthrough.source.data.file.path;
-rc = virSecuritySELinuxRestoreFileLabel(mgr, tpmdev);
+
+if (tpmdev)
+rc = virSecuritySELinuxRestoreFileLabel(mgr, tpmdev);
 
 if ((cancel_path = virTPMCreateCancelPath(tpmdev)) != NULL) {
 if (virSecuritySELinuxRestoreFileLabel(mgr, cancel_path) < 0)
@@ -1722,7 +1725,9 @@ 
virSecuritySELinuxRestoreHostdevCapsLabel(virSecurityManagerPtr mgr,
 if (VIR_STRDUP(path, dev->source.caps.u.storage.block) < 0)
 return -1;
 }
-ret = virSecuritySELinuxRestoreFileLabel(mgr, path);
+if (path)
+ret = virSecuritySELinuxRestoreFileLabel(mgr, path);
+
 VIR_FREE(path);
 break;
 }
@@ -1736,7 +1741,8 @@ 
virSecuritySELinuxRestoreHostdevCapsLabel(virSecurityManagerPtr mgr,
 if (VIR_STRDUP(path, dev->source.caps.u.misc.chardev) < 0)
 return -1;
 }
-ret = virSecuritySELinuxRestoreFileLabel(mgr, path);
+if (path)
+ret = virSecuritySELinuxRestoreFileLabel(mgr, path);
 VIR_FREE(path);
 break;
 }
@@ -1876,13 +1882,15 @@ 
virSecuritySELinuxRestoreChardevLabel(virSecurityManagerPtr mgr,
 switch (dev_source->type) {
 case VIR_DOMAIN_CHR_TYPE_DEV:
 case VIR_DOMAIN_CHR_TYPE_FILE:
-if (virSecuritySELinuxRestoreFileLabel(mgr, 
dev_source->data.file.path) < 0)
-goto done;
+if (dev_source->data.file.path) {
+if (virSecuritySELinuxRestoreFileLabel(mgr, 
dev_source->data.file.path) < 0)
+goto done;
+}
 ret = 0;
 break;
 
 case VIR_DOMAIN_CHR_TYPE_UNIX:
-if (!dev_source->data.nix.listen) {
+if (!dev_source->data.nix.listen && dev_source->data.file.path) {
 if (virSecuritySELinuxRestoreFileLabel(mgr, 
dev_source->data.file.path) < 0)
 goto done;
 }
@@ -1898,7 +1906,8 @@ 
virSecuritySELinuxRestoreChardevLabel(virSecurityManagerPtr mgr,
 (virSecuritySELinuxRestoreFileLabel(mgr, in) < 0)) {
 goto done;
 }
-} else if (virSecuritySELinuxRestoreFileLabel(mgr, 
dev_source->data.file.path) < 0) {
+} else if (dev_source->data.file.path &&
+   virSecuritySELinuxRestoreFileLabel(mgr, 
dev_source->data.file.path) < 0) {
 goto done;
 }
 ret = 0;
-- 
1.8.3.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] security_selinux: Fix crash in virSecuritySELinuxRestoreFileLabel

2016-01-21 Thread Shanzhi Yu
when failed to boot a guest, virSecuritySELinuxRestoreFileLabel
will be called eventually to reset security label, which will
lead a crash if pass null to virFileResolveLink(path, ).

https://bugzilla.redhat.com/show_bug.cgi?id=1300532
Signed-off-by: Shanzhi Yu <s...@redhat.com>
---
 src/security/security_selinux.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c
index 9e98635..c8a7553 100644
--- a/src/security/security_selinux.c
+++ b/src/security/security_selinux.c
@@ -1026,7 +1026,7 @@ virSecuritySELinuxRestoreFileLabel(virSecurityManagerPtr 
mgr,
 
 VIR_INFO("Restoring SELinux context on '%s'", path);
 
-if (virFileResolveLink(path, ) < 0) {
+if (path && virFileResolveLink(path, ) < 0) {
 VIR_WARN("cannot resolve symlink %s: %s", path,
  virStrerror(errno, ebuf, sizeof(ebuf)));
 goto err;
-- 
1.8.3.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [libvirt-test-API] [PATCH] Add test cases for API defineXMLFlags

2015-09-28 Thread Shanzhi Yu
Signed-off-by: Shanzhi Yu <s...@redhat.com>
---
 cases/linux_domain.conf |  22 +
 repos/domain/definewithflags.py | 104 
 2 files changed, 126 insertions(+)
 create mode 100644 repos/domain/definewithflags.py

diff --git a/cases/linux_domain.conf b/cases/linux_domain.conf
index 6315613..7dd9062 100644
--- a/cases/linux_domain.conf
+++ b/cases/linux_domain.conf
@@ -214,6 +214,28 @@ domain:define
 macaddr
 54:52:00:45:c3:8a
 
+domain:undefine
+guestname
+$defaultname
+
+domain:definewithflags
+guestname
+$defaultname
+diskpath
+/var/lib/libvirt/images/libvirt-test-api
+vcpu
+1
+memory
+1048576
+hddriver
+virtio
+nicdriver
+virtio
+macaddr
+54:52:00:45:c3:8a
+flags
+validate
+
 domain:start
 guestname
 $defaultname
diff --git a/repos/domain/definewithflags.py b/repos/domain/definewithflags.py
new file mode 100644
index 000..01a4f15
--- /dev/null
+++ b/repos/domain/definewithflags.py
@@ -0,0 +1,104 @@
+#!/usr/bin/evn python
+
+import os
+import re
+import sys
+import commands
+import string
+import pexpect
+
+import libvirt
+from libvirt import libvirtError
+
+from src import sharedmod
+from utils import utils
+
+required_params = ('guestname', 'diskpath', 'flags',)
+optional_params = {'memory': 1048576,
+   'vcpu': 1,
+   'imageformat' : 'raw',
+   'hddriver' : 'virtio',
+   'nicdriver': 'virtio',
+   'macaddr': '52:54:00:97:e4:28',
+   'uuid' : '05867c1a-afeb-300e-e55e-2673391ae080',
+   'username': None,
+   'password': None,
+   'virt_type': 'kvm',
+   'xml': 'xmls/kvm_guest_define.xml',
+   'guestarch': 'x86_64',
+   'guestmachine': 'pc',
+  }
+
+def check_define_domain(guestname, virt_type, hostname, username, \
+password, logger):
+"""Check define domain result, if define domain is successful,
+   guestname.xml will exist under /etc/libvirt/qemu/
+   and can use virt-xml-validate tool to check the file validity
+"""
+if "kvm" in virt_type:
+path = "/etc/libvirt/qemu/%s.xml" % guestname
+elif "xen" in virt_type:
+path = "/etc/xen/%s" % guestname
+else:
+logger.error("unknown virt type")
+
+if hostname:
+cmd = "ls %s" % path
+ret, output = utils.remote_exec_pexpect(hostname, username, \
+   password, cmd)
+if ret:
+logger.error("guest %s xml file doesn't exsits" % guestname)
+return False
+else:
+return True
+else:
+if os.access(path, os.R_OK):
+return True
+else:
+return False
+
+def definewithflags(params):
+"""Define a domain from xml"""
+logger = params['logger']
+guestname = params['guestname']
+
+xmlstr = params['xml']
+logger.debug("domain xml:\n%s" % xmlstr)
+
+conn = sharedmod.libvirtobj['conn']
+uri = conn.getURI()
+
+hostname = utils.parse_uri(uri)[1]
+username = params.get('username', '')
+password = params.get('password', '')
+virt_type = params.get('virt_type', 'kvm')
+
+flags = params['flags']
+logger.info("The flags are %s" % flags)
+flags_string = flags.split("|")
+flags = 0
+
+logger.info("define domain on %s" % uri)
+
+for flag in flags_string:
+if flag == 'validate':
+flags |= libvirt.VIR_DOMAIN_DEFINE_VALIDATE
+else:
+logger.error("unknow flags")
+return 1
+
+# Define domain from xml
+try:
+conn.defineXMLFlags(xmlstr, flags)
+if check_define_domain(guestname, virt_type, hostname, \
+   username, password, logger):
+logger.info("define a domain from xml is successful")
+else:
+logger.error("fail to check define domain")
+return 1
+except libvirtError, e:
+logger.error("API error message: %s, error code is %s" \
+ % (e.message, e.get_error_code()))
+return 1
+
+return 0
-- 
1.8.3.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [libvirt-test-API] [PATCH] fix some typo

2015-09-28 Thread Shanzhi Yu
Signed-off-by: Shanzhi Yu <s...@redhat.com>
---
 repos/domain/fsinfo.py  | 2 +-
 repos/domain/install_linux_check.py | 2 +-
 repos/domain/install_linux_net.py   | 2 +-
 repos/interface/define.py   | 2 +-
 repos/interface/undefine.py | 4 ++--
 5 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/repos/domain/fsinfo.py b/repos/domain/fsinfo.py
index e6d1bf0..d4614f5 100644
--- a/repos/domain/fsinfo.py
+++ b/repos/domain/fsinfo.py
@@ -81,7 +81,7 @@ def fsinfo(params):
 return 1
 
 fsinfo = vm.fsInfo()
-logger.info("get geust filesystem information")
+logger.info("get guest filesystem information")
 
 mac = get_guest_mac(vm)
 if not mac:
diff --git a/repos/domain/install_linux_check.py 
b/repos/domain/install_linux_check.py
index ab1e7db..bb3cc2a 100644
--- a/repos/domain/install_linux_check.py
+++ b/repos/domain/install_linux_check.py
@@ -99,7 +99,7 @@ def install_linux_check(params):
 Test_Result = 1
 return Test_Result
 
-# Check whether vcpu equals the value set in geust config xml
+# Check whether vcpu equals the value set in guest config xml
 logger.info("check point3: check cpu number in guest equals to \
  the value set in domain config xml")
 vcpunum_expect = int(utils.get_num_vcpus(domain_name))
diff --git a/repos/domain/install_linux_net.py 
b/repos/domain/install_linux_net.py
index 4367d97..7173294 100644
--- a/repos/domain/install_linux_net.py
+++ b/repos/domain/install_linux_net.py
@@ -239,7 +239,7 @@ def install_linux_net(params):
 logger.info("booting guest vm off harddisk failed")
 return 1
 else:
-logger.info("geust is booting up")
+logger.info("guest is booting up")
 else:
 interval = 0
 while(interval < 3600):
diff --git a/repos/interface/define.py b/repos/interface/define.py
index 18ba71b..e0dbcf4 100644
--- a/repos/interface/define.py
+++ b/repos/interface/define.py
@@ -42,7 +42,7 @@ def define(params):
 try:
 conn.interfaceDefineXML(xmlstr, 0)
 if check_define_interface(ifacename):
-logger.info("define a interface form xml is successful")
+logger.info("define a interface from xml is successful")
 else:
 logger.error("fail to check define interface")
 return 1
diff --git a/repos/interface/undefine.py b/repos/interface/undefine.py
index f9b2d74..8b250de 100644
--- a/repos/interface/undefine.py
+++ b/repos/interface/undefine.py
@@ -39,14 +39,14 @@ def undefine(params):
 try:
 ifaceobj.undefine()
 if check_undefine_interface(ifacename):
-logger.info("undefine a interface form xml is successful")
+logger.info("undefine a interface is successful")
 else:
 logger.error("fail to check undefine interface")
 return 1
 except libvirtError, e:
 logger.error("API error message: %s, error code is %s" \
  % (e.message, e.get_error_code()))
-logger.error("fail to undefine a interface from xml")
+logger.error("fail to undefine a interface")
 return 1
 
 return 0
-- 
1.8.3.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [libvirt-test-API] [PATCH] Add two cases for API interfaceAddresses and make small changes to global.cfg

2015-09-28 Thread Shanzhi Yu
Signed-off-by: Shanzhi Yu <s...@redhat.com>
---
 cases/linux_domain.conf| 12 +++
 global.cfg |  8 +++--
 repos/domain/get_guest_network_info.py | 66 ++
 3 files changed, 84 insertions(+), 2 deletions(-)
 create mode 100644 repos/domain/get_guest_network_info.py

diff --git a/cases/linux_domain.conf b/cases/linux_domain.conf
index 8440c61..5b216f9 100644
--- a/cases/linux_domain.conf
+++ b/cases/linux_domain.conf
@@ -66,6 +66,18 @@ domain:set_guest_time
 flags
 sync
 
+domain:get_guest_network_info
+guestname
+$defaultname
+flags
+lease
+
+domain:get_guest_network_info
+guestname
+$defaultname
+flags
+agent
+
 virconn:connection_getAllDomainStats
 stats
 state|cpu|balloon|vcpu|interface|block
diff --git a/global.cfg b/global.cfg
index 56677a5..1b72119 100644
--- a/global.cfg
+++ b/global.cfg
@@ -44,6 +44,8 @@ rhel6u1_i386 = http://
 rhel6u1_x86_64 = http://
 rhel6u2_i386 = http://
 rhel6u2_x86_64 = http://
+rhel7u1_x86_64 = http://
+rhel7u2_x86_64 = http://
 fedora12_i386 = http://
 fedora12_x86_64 = http://
 win2008_i386 = http://
@@ -70,6 +72,8 @@ rhel6_i386_http_ks = http://
 rhel6_x86_64_http_ks = http://
 rhel6u2_i386_http_ks = http://
 rhel6u2_x86_64_http_ks = kickstart.cfg
+rhel7u1_x86_64_http_ks = http://
+rhel7u2_x86_64_http_ks = http://
 fedora12_i386_http_ks = http://
 fedora12_x86_64_http_ks = http://
 
@@ -97,7 +101,7 @@ sourcepath = /media/share
 # also exercise DNS resolution
 #
 [other]
-wget_url = http://
+wget_url = http://libvirt.org/index.html
 
 #
 # The variables section is a set of variables used by the
@@ -127,7 +131,7 @@ defaulthv = kvm
 defaultname = libvirt_test_api
 # default os version to use for installing a new guest
 # the value of it is the first part of 'rhel6u2_x86_64' in [guest] section 
above
-defaultos = rhel6u2
+defaultos = rhel7u2
 # default architecture to use for installing a new guest
 defaultarch = x86_64
 # default the number of vcpu to use for defining or installing a guest
diff --git a/repos/domain/get_guest_network_info.py 
b/repos/domain/get_guest_network_info.py
new file mode 100644
index 000..35bba3b
--- /dev/null
+++ b/repos/domain/get_guest_network_info.py
@@ -0,0 +1,66 @@
+#!/usr/bin/python
+
+import libvirt
+from libvirt import libvirtError
+from src import sharedmod
+
+required_params = ('guestname', 'flags',)
+optional_params = {}
+
+def check_guest_status(domobj):
+"""check guest current status
+"""
+state = domobj.info()[0]
+if state == libvirt.VIR_DOMAIN_SHUTOFF or \
+state == libvirt.VIR_DOMAIN_SHUTDOWN:
+return False
+else:
+return True
+
+def get_guest_network_info(params):
+"""get guest network interface info
+"""
+
+logger = params['logger']
+guestname = params['guestname']
+flags = params['flags']
+
+conn = sharedmod.libvirtobj['conn']
+
+domobj = conn.lookupByName(guestname)
+
+flags = params['flags']
+logger.info("The flags are %s" % flags)
+flags_string = flags.split("|")
+flags = 0
+
+for flag in flags_string:
+if flag  == 'lease':
+flags |= libvirt.VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_LEASE
+elif flag == 'agent':
+flags |= libvirt.VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_AGENT
+else:
+logger.error("unknow flags")
+return 1
+
+logger.info("the given flags is %d" % flags)
+
+# Check domain status
+if check_guest_status(domobj):
+logger.info("Guest is running")
+else:
+logger.error("Guest is shut off status")
+return 1
+
+try:
+info = domobj.interfaceAddresses(flags)
+logger.info("get guest interface info")
+
+except libvirtError, e:
+logger.error("API error message: %s, error code is %s" \
+% (e.message, e.get_error_code()))
+return 1
+
+return 0
+
+
-- 
1.8.3.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [libvirt-test-API] [PATCH] fix two error in script pin_iothread.py and connection_getAllDomainStats.py

2015-09-28 Thread Shanzhi Yu
Signed-off-by: Shanzhi Yu <s...@redhat.com>
---
 repos/domain/pin_iothread.py  | 2 +-
 repos/virconn/connection_getAllDomainStats.py | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/repos/domain/pin_iothread.py b/repos/domain/pin_iothread.py
index 28ee2c4..d2d812f 100644
--- a/repos/domain/pin_iothread.py
+++ b/repos/domain/pin_iothread.py
@@ -116,7 +116,7 @@ def pin_iothread(params):
 
 if not find_iothreadid_fromxml(vm, 1, 1):
 logger.info("add iothread %d to running guest" % 1)
-vm.addIOThread(i, libvirt.VIR_DOMAIN_AFFECT_LIVE)
+vm.addIOThread(1, libvirt.VIR_DOMAIN_AFFECT_LIVE)
 
 vm.pinIOThread(1, tu_cpu, libvirt.VIR_DOMAIN_AFFECT_LIVE)
 cpuset = find_iothreadpin_fromxml(vm, 1, 1)
diff --git a/repos/virconn/connection_getAllDomainStats.py 
b/repos/virconn/connection_getAllDomainStats.py
index d95004f..3362444 100644
--- a/repos/virconn/connection_getAllDomainStats.py
+++ b/repos/virconn/connection_getAllDomainStats.py
@@ -164,7 +164,7 @@ def check_each_vcpu(logger,dom_name,dom_active,dom_eles):
 if not vcpu_cur:
 for i in range(0,vcpu_max):
 vcpu_pre = "vcpu."+ str(i) + "."
-logger.debug("Checking %sstate: %d" \
+logger.debug("Checking %sstate: %s" \
 %(vcpu_pre, dom_eles.get(vcpu_pre + "state")))
 if not compare_value(logger,vcpu_stat, \
 dom_eles.get(vcpu_pre + "state")):
@@ -172,7 +172,7 @@ def check_each_vcpu(logger,dom_name,dom_active,dom_eles):
 elif int(vcpu_cur.nodeValue) <= vcpu_max:
 for i in range(0,int(vcpu_cur.nodeValue)):
 vcpu_pre = "vcpu."+ str(i) + "."
-logger.debug("Checking %sstate: %d" \
+logger.debug("Checking %sstate: %s" \
 %(vcpu_pre, dom_eles.get(vcpu_pre + "state")))
 if not compare_value(logger,vcpu_stat, \
 dom_eles.get(vcpu_pre + "state")):
-- 
1.8.3.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [libvirt-test-API] [PATCH] change some cases order in conf file linux_domain.conf

2015-09-28 Thread Shanzhi Yu
Some cases need guest agent running in domain, change some cases order
to avoid the failure.

Signed-off-by: Shanzhi Yu <s...@redhat.com>
---
 cases/linux_domain.conf | 100 
 1 file changed, 50 insertions(+), 50 deletions(-)

diff --git a/cases/linux_domain.conf b/cases/linux_domain.conf
index 5b216f9..6315613 100644
--- a/cases/linux_domain.conf
+++ b/cases/linux_domain.conf
@@ -78,6 +78,56 @@ domain:get_guest_network_info
 flags
 agent
 
+domain:domain_fsfreeze
+guestname
+$defaultname
+
+domain:domain_fsthaw
+guestname
+$defaultname
+
+domain:domain_fsfreeze
+guestname
+$defaultname
+mountpoint
+/
+
+domain:domain_fsthaw
+guestname
+$defaultname
+
+domain:fsinfo
+guestname
+$defaultname
+username
+$username
+userpassword
+$password
+conn
+qemu:///system
+
+domain:set_user_passwd
+guestname
+$defaultname
+username
+$username
+userpassword
+$password
+conn
+qemu:///system
+
+domain:set_user_passwd
+guestname
+$defaultname
+username
+$username
+userpassword
+$password
+conn
+qemu:///system
+flags
+encrypted
+
 virconn:connection_getAllDomainStats
 stats
 state|cpu|balloon|vcpu|interface|block
@@ -259,24 +309,6 @@ domain:open_graphicsfd
 flags
skipauth
 
-domain:domain_fsfreeze
-guestname
-$defaultname
-
-domain:domain_fsthaw
-guestname
-$defaultname
-
-domain:domain_fsfreeze
-guestname
-$defaultname
-mountpoint
-/
-
-domain:domain_fsthaw
-guestname
-$defaultname
-
 virconn:connection_security_model
 guestname
 $defaultname
@@ -311,38 +343,6 @@ domain:info_iothread
 conn
 qemu:///system
 
-domain:fsinfo
-guestname
-$defaultname
-username
-$username
-userpassword
-$password
-conn
-qemu:///system
-
-domain:set_user_passwd
-guestname
-$defaultname
-username
-$username
-userpassword
-$password
-conn
-qemu:///system
-
-domain:set_user_passwd
-guestname
-$defaultname
-username
-$username
-userpassword
-$password
-conn
-qemu:///system
-flags
-encrypted
-
 domain:destroy
 guestname
 $defaultname
-- 
1.8.3.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] qemu: blockcopy: Forbid using persistent bitmap granularity with raw vols

2015-06-24 Thread Shanzhi Yu


On 06/24/2015 03:11 PM, Peter Krempa wrote:
 qemu returns error but only in the event after the block job actually
 starts. Reject it upfront for a better error message.

 Instead of:
 $ virsh blockcopy vm hdc /tmp/raw.img --granularity 4096 --verbose --wait
 error: Block Copy unexpectedly failed

 You will now get:
 $ virsh blockcopy vm hdc /tmp/raw.img --granularity 4096 --verbose --wait
 error: unsupported configuration: granularity can't be used with target 
 volume format

This can't avoid the cases that the source file has a raw format file as
backing file.


 Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1233115
 ---
  src/qemu/qemu_driver.c | 10 ++
  1 file changed, 10 insertions(+)

 diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
 index c1373de..f570879 100644
 --- a/src/qemu/qemu_driver.c
 +++ b/src/qemu/qemu_driver.c
 @@ -16671,6 +16671,16 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm,
  goto endjob;
  }

 +/* blacklist granularity with some known-bad formats */
 +if (granularity 
 +(mirror-format == VIR_STORAGE_FILE_RAW ||
 + (mirror-format = VIR_STORAGE_FILE_NONE 
 +  disk-src-format == VIR_STORAGE_FILE_RAW))) {
 +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s,
 +   _(granularity can't be used with target volume 
 format));
 +goto endjob;
 +}
 +
  /* Prepare the destination file.  */
  /* XXX Allow non-file mirror destinations */
  if (!virStorageSourceIsLocalStorage(mirror)) {

-- 
Regards
shyu

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] qemu: blockcopy: Forbid using persistent bitmap granularity with raw vols

2015-06-24 Thread Shanzhi Yu


On 06/24/2015 05:33 PM, Peter Krempa wrote:
 On Wed, Jun 24, 2015 at 16:48:16 +0800, Shanzhi Yu wrote:

 On 06/24/2015 03:11 PM, Peter Krempa wrote:
 qemu returns error but only in the event after the block job actually
 starts. Reject it upfront for a better error message.

 Instead of:
 $ virsh blockcopy vm hdc /tmp/raw.img --granularity 4096 --verbose --wait
 error: Block Copy unexpectedly failed

 You will now get:
 $ virsh blockcopy vm hdc /tmp/raw.img --granularity 4096 --verbose --wait
 error: unsupported configuration: granularity can't be used with target 
 volume format
 This can't avoid the cases that the source file has a raw format file as
 backing file.
 AFAIK if the active image (top layer) is a qcow2, then the destination
 is also created as a qcow2 and thus the persistent bitmap granularity
 should work just fine.

Consider I have a guest as below:

# virsh dumpxml r7-raw|grep disk -A 8
disk type='file' device='disk'
  driver name='qemu' type='qcow2'/
  source file='/var/lib/libvirt/images/rhel7-raw.s1'/
  backingStore type='file' index='1'
format type='raw'/
source file='/var/lib/libvirt/images/rhel7-raw.img'/
backingStore/
  /backingStore
  target dev='vda' bus='virtio'/

case I:
# virsh blockcopy r7-raw vda /var/lib/libvirt/images/rhel7-raw.s1.cp  
--verbose --wait --granularity 4096 
error: Block Copy unexpectedly failed

case II:
# virsh blockcopy r7-raw vda /var/lib/libvirt/images/rhel7-raw.s1.cp  
--verbose --wait --granularity 4096  --shallow
Block Copy: [  0 %]error: Block Copy unexpectedly failed


 Peter

-- 
Regards
shyu

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] qemu: add value range check of option granularity

2015-06-16 Thread Shanzhi Yu
The default value of the granularity is the image cluster size clamped
between 4096 and 65536. Libvirt should add a check for this otherwise
qemu will report error like below:

$ virsh blockcopy r7 vda /var/lib/libvirt/images/r7.s1   --granularity  32
error: internal error: unable to execute QEMU command 'drive-mirror': Parameter 
'granularity' expects a value in range [512B, 64MB]

Signed-off-by: Shanzhi Yu s...@redhat.com
---
 src/qemu/qemu_driver.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index d1f195c..0eca8ed 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -16990,6 +16990,10 @@ qemuDomainBlockCopy(virDomainPtr dom, const char 
*disk, const char *destxml,
 virReportError(VIR_ERR_INVALID_ARG, %s,
_(granularity must be power of 2));
 goto cleanup;
+} else if (param-value.ui  65536 || param-value.ui  4096) {
+virReportError(VIR_ERR_INVALID_ARG, %s,
+   _(granularity expects value in range [4096 
65536]));
+goto cleanup;
 }
 granularity = param-value.ui;
 } else if (STREQ(param-field, VIR_DOMAIN_BLOCK_COPY_BUF_SIZE)) {
-- 
2.4.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] tools: fix the output of blockjob

2015-05-10 Thread Shanzhi Yu
There will be no output when use blockjob with --raw option if guest
has no block job. A explicit message should be given just like
with --info

Signed-off-by: Shanzhi Yu s...@redhat.com
---
 tools/virsh-domain.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 14e1e35..7094a43 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -2541,7 +2541,6 @@ cmdBlockJob(vshControl *ctl, const vshCmd *cmd)
 }
 
 if (rc == 0) {
-if (!raw)
 vshPrint(ctl, _(No current block job for %s), path);
 ret = true;
 goto cleanup;
-- 
2.1.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] qemu: Fix the crash in qemuDomainBlockCopyCommon

2015-04-27 Thread Shanzhi Yu


On 04/27/2015 05:57 PM, Peter Krempa wrote:
 On Mon, Apr 27, 2015 at 15:38:57 +0800, Shanzhi Yu wrote:
 The crash caused when checking the backing file path of a disk while
 the disk has no backing file, add a check before using 
 disk-src-backingStore-path

 Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1215569
 ---
  src/qemu/qemu_driver.c | 9 +
  1 file changed, 9 insertions(+)

 diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
 index 70bf7aa..175d00b 100644
 --- a/src/qemu/qemu_driver.c
 +++ b/src/qemu/qemu_driver.c
 @@ -16816,6 +16816,15 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm,
  goto endjob;
  
  if ((flags  VIR_DOMAIN_BLOCK_COPY_SHALLOW) 
 +!disk-src-backingStore) {
 +virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
 +   _(disk '%s' has no backing file, so shallow copy 
 + is not possible),
 Well, we can also discard the SHALLOW flag in case the backing file is
 not present since it will behave semantically correctly that way.


 +   disk-src-path);
 +goto endjob;
 +}
 +
 +if ((flags  VIR_DOMAIN_BLOCK_COPY_SHALLOW) 
  mirror-format == VIR_STORAGE_FILE_RAW 
  disk-src-backingStore-path) {
  virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
 The docs correctly state that for shallow copy the reused file has to
 have the same guest visible contents as the backing file of the current
 file so this condition can be removed altogether fixing the crash.

 I'll post a different approach soon.

Ok, thanks

 Peter

-- 
Regards
shyu

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] qemu: Fix the crash in qemuDomainBlockCopyCommon

2015-04-27 Thread Shanzhi Yu
The crash caused when checking the backing file path of a disk while
the disk has no backing file, add a check before using 
disk-src-backingStore-path

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1215569
---
 src/qemu/qemu_driver.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 70bf7aa..175d00b 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -16816,6 +16816,15 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm,
 goto endjob;
 
 if ((flags  VIR_DOMAIN_BLOCK_COPY_SHALLOW) 
+!disk-src-backingStore) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+   _(disk '%s' has no backing file, so shallow copy 
+ is not possible),
+   disk-src-path);
+goto endjob;
+}
+
+if ((flags  VIR_DOMAIN_BLOCK_COPY_SHALLOW) 
 mirror-format == VIR_STORAGE_FILE_RAW 
 disk-src-backingStore-path) {
 virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-- 
2.1.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] qemu: blockCopy: Allow shallow block copy into a raw image

2015-04-27 Thread Shanzhi Yu


On 04/27/2015 08:01 PM, Peter Krempa wrote:
 The documentation states that for shallow block copy the image has to
 have the same guest visible content as backing file of the current
 image. This condition can be achieved also with a raw file (or a qcow
 without a backing file) so remove the condition that would disallow it.

 (This patch additionally fixes crash described in
  https://bugzilla.redhat.com/show_bug.cgi?id=1215569 since it removes
  the code)
 ---
  src/qemu/qemu_driver.c | 10 --
  1 file changed, 10 deletions(-)

 diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
 index 70bf7aa..f979d33 100644
 --- a/src/qemu/qemu_driver.c
 +++ b/src/qemu/qemu_driver.c
 @@ -16815,16 +16815,6 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm,
  if (qemuDomainDetermineDiskChain(driver, vm, disk, false, true)  0)
  goto endjob;

 -if ((flags  VIR_DOMAIN_BLOCK_COPY_SHALLOW) 
 -mirror-format == VIR_STORAGE_FILE_RAW 
 -disk-src-backingStore-path) {
 -virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
 -   _(disk '%s' has backing file, so raw shallow copy 
 - is not possible),
 -   disk-dst);
 -goto endjob;
 -}
 -

Although a shallow blockcopy of file without backing file is
semantically correct, but still feel a little weird.
And, a shallow blockcommit of file without backing file will failed with
error
error: invalid argument: top '/var/lib/libvirt/images/raw.img' in chain
for 'vda' has no backing file

Should libvirt post error when try a shallow blockcopy of file without
backing file, just as shallow blockcommit?

  /* Prepare the destination file.  */
  /* XXX Allow non-file mirror destinations */
  if (!virStorageSourceIsLocalStorage(mirror)) {

-- 
Regards
shyu

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] qemu: blockCopy: Allow shallow block copy into a raw image

2015-04-27 Thread Shanzhi Yu


On 04/27/2015 11:38 PM, Peter Krempa wrote:
 On Mon, Apr 27, 2015 at 22:11:40 +0800, Shanzhi Yu wrote:

 On 04/27/2015 08:01 PM, Peter Krempa wrote:
 The documentation states that for shallow block copy the image has to
 have the same guest visible content as backing file of the current
 image. This condition can be achieved also with a raw file (or a qcow
 without a backing file) so remove the condition that would disallow it.

 (This patch additionally fixes crash described in
  https://bugzilla.redhat.com/show_bug.cgi?id=1215569 since it removes
  the code)
 ---
  src/qemu/qemu_driver.c | 10 --
  1 file changed, 10 deletions(-)

 diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
 index 70bf7aa..f979d33 100644
 --- a/src/qemu/qemu_driver.c
 +++ b/src/qemu/qemu_driver.c
 @@ -16815,16 +16815,6 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm,
  if (qemuDomainDetermineDiskChain(driver, vm, disk, false, true)  0)
  goto endjob;

 -if ((flags  VIR_DOMAIN_BLOCK_COPY_SHALLOW) 
 -mirror-format == VIR_STORAGE_FILE_RAW 
 -disk-src-backingStore-path) {
 -virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
 -   _(disk '%s' has backing file, so raw shallow copy 
 - is not possible),
 -   disk-dst);
 -goto endjob;
 -}
 -
 Although a shallow blockcopy of file without backing file is
 semantically correct, but still feel a little weird.
 And, a shallow blockcommit of file without backing file will failed with
 error
 error: invalid argument: top '/var/lib/libvirt/images/raw.img' in chain
 for 'vda' has no backing file

 Should libvirt post error when try a shallow blockcopy of file without
 backing file, just as shallow blockcommit?
 I cannot reproduce the error above, could you please post steps to do
 that? or perhaps debug log from libvirt?

It is easy to reproduce. Suppose live guest xml looks like:

# virsh dumpxml vm1|grep disk -A 8
disk type='file' device='disk'
  driver name='qemu' type='qcow2'/
  source file='/var/lib/libvirt/images/raw.1430143276'/
  backingStore type='file' index='1'
format type='raw'/
source file='/var/lib/libvirt/images/raw.img'/
backingStore/
  /backingStore
  target dev='vda' bus='virtio'/
  alias name='virtio-disk0'/
  address type='pci' domain='0x' bus='0x00' slot='0x03'
function='0x0'/
/disk

Then try a shallow blockcommit of file has no backing file

# virsh blockcommit vm1 vda --top vda[1] --shallow
error: invalid argument: top '/var/lib/libvirt/images/raw.img' in chain
for 'vda' has no backing file



 When copying from a single layer image with the --shallow flag I'm able
 to successfully copy both into a raw and a qcow2 file.

I also can do it.
But a shallow block copy of file which has backing file into a raw  file
does not make any sense, right?

  /* Prepare the destination file.  */
  /* XXX Allow non-file mirror destinations */
  if (!virStorageSourceIsLocalStorage(mirror)) {
 Peter

-- 
Regards
shyu

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] qemu: save domain status after set memory parameters

2015-04-14 Thread Shanzhi Yu
After set memory parameters for running domain, save the change to live
xml is needed otherwise it will disappear after restart libvirtd.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1211548
Signed-off-by: Shanzhi Yu s...@redhat.com
---
 src/qemu/qemu_driver.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index e790664..2e4504e 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -9843,6 +9843,9 @@ qemuDomainSetMemoryParameters(virDomainPtr dom,
 
 #undef QEMU_SET_MEM_PARAMETER
 
+if (virDomainSaveStatus(driver-xmlopt, cfg-stateDir, vm)  0)
+goto endjob;
+
 if (flags  VIR_DOMAIN_AFFECT_CONFIG 
 virDomainSaveConfig(cfg-configDir, persistentDef)  0)
 goto endjob;
-- 
2.1.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] tools: improve the error info when fail to parse parameter --soft-limit of memtune

2015-04-14 Thread Shanzhi Yu
When set guest memory with a invalid parameter of --soft-limit, it posts weird 
error:

$ virsh memtune r7 --hard-limit 20417224 --soft-limit 9007199254740992  
--swap-hard-limit 35417224
error: Unable to parse integer parameter 'NAME

Change it to

error: Unable to parse integer parameter soft-limit

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1211550
Signed-off-by: Shanzhi Yu s...@redhat.com
---
 tools/virsh-domain.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 3e2c420..ebdf398 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -8417,7 +8417,7 @@ cmdMemtune(vshControl *ctl, const vshCmd *cmd)
 
 #define PARSE_MEMTUNE_PARAM(NAME, FIELD)\
 if ((rc = vshMemtuneGetSize(cmd, NAME, tmpVal))  0) { \
-vshError(ctl, %s, _(Unable to parse integer parameter 'NAME')); \
+vshError(ctl, _(Unable to parse integer parameter %s), NAME); \
 goto cleanup;   \
 }   \
 if (rc == 1) {  \
-- 
2.1.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] qemu: save domain status after set memory parameters

2015-04-14 Thread Shanzhi Yu


On 04/14/2015 07:54 PM, Ján Tomko wrote:
 On Tue, Apr 14, 2015 at 06:24:41PM +0800, Shanzhi Yu wrote:
 After set memory parameters for running domain, save the change to live
 xml is needed otherwise it will disappear after restart libvirtd.

 Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1211548
 Signed-off-by: Shanzhi Yu s...@redhat.com
 ---
  src/qemu/qemu_driver.c | 3 +++
  1 file changed, 3 insertions(+)

 diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
 index e790664..2e4504e 100644
 --- a/src/qemu/qemu_driver.c
 +++ b/src/qemu/qemu_driver.c
 @@ -9843,6 +9843,9 @@ qemuDomainSetMemoryParameters(virDomainPtr dom,
  
  #undef QEMU_SET_MEM_PARAMETER
  
 +if (virDomainSaveStatus(driver-xmlopt, cfg-stateDir, vm)  0)
 +goto endjob;
 This should only be done if flags  VIR_DOMAIN_AFFECT_LIVE.

 ACK and pushed with that change.

Oh, right.
Thanks for your review for both.


 Jan

-- 
Regards
shyu

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [RFC] How to build libvirt package with git commit info from libvirt.git

2015-03-31 Thread Shanzhi Yu
Hello there,

Currently I am searching a way to build a libvirt package from latest
libvirt.git with package name including git commit info.
Like
# cd libvirt  git describe
v1.2.14-rc1-16-g0c4474d

then I want to build a libvirt package with name like
libvirt-1.2.14-1.el7.v1.2.14-rc1-16-g0c4474d.x86_64

The context why I need this  is there are some hosts running scripts for
auto QE-consumption testing while there is no job
running sometimes.( we won't get a internal release version everyday, it
is not necessary also). We can make use of these
resource to do some auto testing daily so that we may be able to find
the regression problems earlier.
So, a package with commit info is required for comparative testing.

After talk with eblake I got a way as below:
after 'make rpm' , I will get libvirt.spec,
then I can tweak libvirt.spec add a line %define extra_release
.git_commit_num at the top of libvirt.spec
then use the tweaked libvirt.spec to build the package I want to get

I wonder anybody have a better method to achieve this ?


Thanks

-- 
Regards
shyu

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] qemu: end the job when try to blockcopy to non-file destination

2015-03-27 Thread Shanzhi Yu
Blockcopy to non-file destination is not supported according the code while
a 'goto endjob' is missed after check the destination which lead qemu try
to do drive-mirror.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1206406
Signed-off-by: Shanzhi Yu s...@redhat.com
---
 src/qemu/qemu_driver.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index db4f0b4..f07e4fb 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -16642,6 +16642,7 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm,
 if (!virStorageSourceIsLocalStorage(mirror)) {
 virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, %s,
_(non-file destination not supported yet));
+goto endjob;
 }
 if (stat(mirror-path, st)  0) {
 if (errno != ENOENT) {
-- 
2.1.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] conf: refact virDomainHasDiskMirror and rename it to virDomainHasBlockjob

2015-03-26 Thread Shanzhi Yu
- Original Message -

| From: Peter Krempa pkre...@redhat.com
| To: Shanzhi Yu s...@redhat.com
| Cc: libvir-list@redhat.com
| Sent: Wednesday, March 25, 2015 11:24:21 PM
| Subject: Re: [libvirt] [PATCH] conf: refact virDomainHasDiskMirror and rename
| it to virDomainHasBlockjob

| On Tue, Mar 24, 2015 at 18:08:00 +0800, Shanzhi Yu wrote:
|  Create external snapshot or migrate a vm when there is a blockpull
|  job running should be forbidden by libvirt, otherwise qemu try to
|  create external snapshot and failed with error unable to execute
|  QEMU command 'transaction': Device 'drive-virtio-disk0' is busy:
|  block device is in use by block job: stream, and migration will
|  succeed which will lead the blockpull job failed.
| 
|  Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1203628
|  Signed-off-by: Shanzhi Yu s...@redhat.com
|  ---
|  src/conf/domain_conf.c | 6 +++---
|  src/conf/domain_conf.h | 2 +-
|  src/libvirt_private.syms | 2 +-
|  src/qemu/qemu_driver.c | 6 +++---
|  src/qemu/qemu_migration.c | 2 +-
|  5 files changed, 9 insertions(+), 9 deletions(-)
| 
|  diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
|  index d633f93..24445af 100644
|  --- a/src/conf/domain_conf.c
|  +++ b/src/conf/domain_conf.c
|  @@ -12264,13 +12264,13 @@ virDomainDiskRemoveByName(virDomainDefPtr def,
|  const char *name)
|  }
| 
|  /* Return true if VM has at least one disk involved in a current block
|  - * copy/commit job (that is, with a mirror element in the disk xml). */
|  + * copy/commit/pull job */
|  bool
|  -virDomainHasDiskMirror(virDomainObjPtr vm)
|  +virDomainHasBlockjob(virDomainObjPtr vm)
|  {
|  size_t i;
|  for (i = 0; i  vm-def-ndisks; i++)
|  - if (vm-def-disks[i]-mirror)
|  + if (vm-def-disks[i]-blockjob)
|  return true;
|  return false;
|  }
|  diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
|  index bceb2d7..32674f3 100644
|  --- a/src/conf/domain_conf.h
|  +++ b/src/conf/domain_conf.h
|  @@ -2645,7 +2645,7 @@ int virDomainDiskSourceParse(xmlNodePtr node,
|  xmlXPathContextPtr ctxt,
|  virStorageSourcePtr src);
| 
|  -bool virDomainHasDiskMirror(virDomainObjPtr vm);
|  +bool virDomainHasBlockjob(virDomainObjPtr vm);
| 
|  int virDomainNetFindIdx(virDomainDefPtr def, virDomainNetDefPtr net);
|  virDomainNetDefPtr virDomainNetFind(virDomainDefPtr def, const char
|  *device);
|  diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
|  index 33222f0..9ebaf4a 100644
|  --- a/src/libvirt_private.syms
|  +++ b/src/libvirt_private.syms
|  @@ -297,7 +297,7 @@ virDomainGraphicsTypeFromString;
|  virDomainGraphicsTypeToString;
|  virDomainGraphicsVNCSharePolicyTypeFromString;
|  virDomainGraphicsVNCSharePolicyTypeToString;
|  -virDomainHasDiskMirror;
|  +virDomainHasBlockjob;
|  virDomainHasNet;
|  virDomainHostdevCapsTypeToString;
|  virDomainHostdevDefAlloc;
|  diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
|  index 80a3d77..51e302f 100644
|  --- a/src/qemu/qemu_driver.c
|  +++ b/src/qemu/qemu_driver.c
|  @@ -7398,7 +7398,7 @@ static virDomainPtr
|  qemuDomainDefineXMLFlags(virConnectPtr conn, const char *xml
| 
|  virObjectRef(vm);
|  def = NULL;
|  - if (virDomainHasDiskMirror(vm)) {
|  + if (virDomainHasBlockjob(vm)) {
|  virReportError(VIR_ERR_BLOCK_COPY_ACTIVE, %s,
|  _(domain has active block job));
|  virDomainObjAssignDef(vm, NULL, false, NULL);

| This code here has two effects:

| 1) if the VM is started, this is to forbid defining it back
| 2) if the VM is not started it forbids defining one with a disk mirror
| element

| Additionally this check (in the existing form) is wrong since the active
| block copy job should not interlock domain definition.

| Whith this patch the check would be even more wrong as it would disallow
| changes to the persistent defintion if any block job was active.
Understood 

| This problem needs to be fixed separately, before attempting such
| change.
|  @@ -14583,7 +14583,7 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
|  %s, _(domain is marked for auto destroy));
|  goto cleanup;
|  }
|  - if (virDomainHasDiskMirror(vm)) {
|  + if (virDomainHasBlockjob(vm)) {
|  virReportError(VIR_ERR_BLOCK_COPY_ACTIVE, %s,
|  _(domain has active block job));
|  goto cleanup;

| I think we should reconsider whether we want to block snapshots by a
| single copy job or we want to do the check in a more granular (per-disk)
Yes, it's better check per disk. 

| fashion.

|  @@ -15245,7 +15245,7 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr
|  snapshot,
|  if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|  goto cleanup;
| 
|  - if (virDomainHasDiskMirror(vm)) {
|  + if (virDomainHasBlockjob(vm)) {
|  virReportError(VIR_ERR_BLOCK_COPY_ACTIVE, %s,
|  _(domain has active block job));
|  goto cleanup;

| Here it's questionable whether combining the check for

|  diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
|  index d34bb02..27a76ec 100644
|  --- a/src/qemu/qemu_migration.c
|  +++ b/src

[libvirt] [PATCH] conf: refact virDomainHasDiskMirror and rename it to virDomainHasBlockjob

2015-03-24 Thread Shanzhi Yu
Create external snapshot or migrate a vm when there is a blockpull
job running should be forbidden by libvirt, otherwise qemu try to
create external snapshot and failed with error unable to execute
QEMU command 'transaction': Device 'drive-virtio-disk0' is busy:
block device is in use by block job: stream, and migration will
succeed which will lead the blockpull job failed.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1203628
Signed-off-by: Shanzhi Yu s...@redhat.com
---
 src/conf/domain_conf.c| 6 +++---
 src/conf/domain_conf.h| 2 +-
 src/libvirt_private.syms  | 2 +-
 src/qemu/qemu_driver.c| 6 +++---
 src/qemu/qemu_migration.c | 2 +-
 5 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index d633f93..24445af 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -12264,13 +12264,13 @@ virDomainDiskRemoveByName(virDomainDefPtr def, const 
char *name)
 }
 
 /* Return true if VM has at least one disk involved in a current block
- * copy/commit job (that is, with a mirror element in the disk xml).  */
+ * copy/commit/pull job */
 bool
-virDomainHasDiskMirror(virDomainObjPtr vm)
+virDomainHasBlockjob(virDomainObjPtr vm)
 {
 size_t i;
 for (i = 0; i  vm-def-ndisks; i++)
-if (vm-def-disks[i]-mirror)
+if (vm-def-disks[i]-blockjob)
 return true;
 return false;
 }
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index bceb2d7..32674f3 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2645,7 +2645,7 @@ int virDomainDiskSourceParse(xmlNodePtr node,
  xmlXPathContextPtr ctxt,
  virStorageSourcePtr src);
 
-bool virDomainHasDiskMirror(virDomainObjPtr vm);
+bool virDomainHasBlockjob(virDomainObjPtr vm);
 
 int virDomainNetFindIdx(virDomainDefPtr def, virDomainNetDefPtr net);
 virDomainNetDefPtr virDomainNetFind(virDomainDefPtr def, const char *device);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 33222f0..9ebaf4a 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -297,7 +297,7 @@ virDomainGraphicsTypeFromString;
 virDomainGraphicsTypeToString;
 virDomainGraphicsVNCSharePolicyTypeFromString;
 virDomainGraphicsVNCSharePolicyTypeToString;
-virDomainHasDiskMirror;
+virDomainHasBlockjob;
 virDomainHasNet;
 virDomainHostdevCapsTypeToString;
 virDomainHostdevDefAlloc;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 80a3d77..51e302f 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -7398,7 +7398,7 @@ static virDomainPtr 
qemuDomainDefineXMLFlags(virConnectPtr conn, const char *xml
 
 virObjectRef(vm);
 def = NULL;
-if (virDomainHasDiskMirror(vm)) {
+if (virDomainHasBlockjob(vm)) {
 virReportError(VIR_ERR_BLOCK_COPY_ACTIVE, %s,
_(domain has active block job));
 virDomainObjAssignDef(vm, NULL, false, NULL);
@@ -14583,7 +14583,7 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
%s, _(domain is marked for auto destroy));
 goto cleanup;
 }
-if (virDomainHasDiskMirror(vm)) {
+if (virDomainHasBlockjob(vm)) {
 virReportError(VIR_ERR_BLOCK_COPY_ACTIVE, %s,
_(domain has active block job));
 goto cleanup;
@@ -15245,7 +15245,7 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr 
snapshot,
 if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
 goto cleanup;
 
-if (virDomainHasDiskMirror(vm)) {
+if (virDomainHasBlockjob(vm)) {
 virReportError(VIR_ERR_BLOCK_COPY_ACTIVE, %s,
_(domain has active block job));
 goto cleanup;
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index d34bb02..27a76ec 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -1977,7 +1977,7 @@ qemuMigrationIsAllowed(virQEMUDriverPtr driver, 
virDomainObjPtr vm,
 
 }
 
-if (virDomainHasDiskMirror(vm)) {
+if (virDomainHasBlockjob(vm)) {
 virReportError(VIR_ERR_OPERATION_INVALID, %s,
_(domain has an active block job));
 return false;
-- 
2.1.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] Domain XML isn't dumping full backing chain

2015-03-18 Thread Shanzhi Yu
- Original Message -

| From: Deepak Shetty dpkshe...@gmail.com
| To: libvir-list@redhat.com
| Sent: Wednesday, March 18, 2015 7:19:05 PM
| Subject: [libvirt] Domain XML isn't dumping full backing chain

| Hi,
| I am using libvirt version 1.2.9.2 on F21 and i am unable to get the complete
| backing chain info in the virsh dumpxml output. Details below :

| My backing chain per qemu-img :

| [stack@devstack-f21 test]$ qemu-img info --backing-chain snap4.qcow2
| image: snap4.qcow2
| file format: qcow2
| virtual size: 1.0G (1073741824 bytes)
| disk size: 196K
| cluster_size: 65536
| backing file: ./snap3.qcow2
| Format specific information:
| compat: 1.1
| lazy refcounts: false

| image: ./snap3.qcow2
| file format: qcow2
| virtual size: 1.0G (1073741824 bytes)
| disk size: 196K
| cluster_size: 65536
| backing file: ./snap2.qcow2 (actual path: ././snap2.qcow2)
| Format specific information:
| compat: 1.1
| lazy refcounts: false

| image: ././snap2.qcow2
| file format: qcow2
| virtual size: 1.0G (1073741824 bytes)
| disk size: 196K
| cluster_size: 65536
| backing file: ./snap1.qcow2 (actual path: ./././snap1.qcow2)
| Format specific information:
| compat: 1.1
| lazy refcounts: false

| image: ./././snap1.qcow2
| file format: qcow2
| virtual size: 1.0G (1073741824 bytes)
| disk size: 196K
| cluster_size: 65536
| backing file: ./base.qcow2 (actual path: ././././base.qcow2)
| Format specific information:
| compat: 1.1
| lazy refcounts: false

| image: ././././base.qcow2
| file format: qcow2
| virtual size: 1.0G (1073741824 bytes)
| disk size: 196K
| cluster_size: 65536
| Format specific information:
| compat: 1.1
| lazy refcounts: false

If you want prepare the backing chain yourself, you should add -o 
backing_fmt=$farmat options, 
like qemu-img create -f qcow2 base.s1 -b base.qcow2 -o backing_fmt=qcow2 

| I created 4 snapshots using commands (similar to the below, just dumping the
| last one here ):

| [stack@devstack-f21 test]$ virsh snapshot-create-as test-domain on-test-snap4
| --disk-only --reuse-external --diskspec
| hda,snapshot=external,file=/home/stack/test/snap4.qcow2
| Domain snapshot on-test-snap4 created

| [stack@devstack-f21 test]$ virsh domblklist test-domain
| Target Source
| 
| hda /home/stack/test/snap4.qcow2

| virsh dumpxml test-domain|more
| 

| disk type='file' device='disk'
| driver name='qemu' type='qcow2' cache='none'/
| source file='/home/stack/test/snap4.qcow2'/
| backingStore type='file' index='1'
| format type='raw'/

If you don't add -o backing_fmt=qcow2, it will treat backing file format as 
raw format. 
Since a raw format file doesn't have a backing file, so you only see 
snap4.qcow2 and 
snap3.qcow2 

| source file='/home/stack/test/./snap3.qcow2'/
| backingStore/
| /backingStore
| target dev='hda' bus='ide'/
| alias name='ide0-0-0'/
| address type='drive' controller='0' bus='0' target='0' unit='0'/
| /disk

| .

| I think thats happening beccause the backingStore format is coming as 'raw'
| What am i missing ?

| thanx,
| deepak

| --
| libvir-list mailing list
| libvir-list@redhat.com
| https://www.redhat.com/mailman/listinfo/libvir-list
-- 
Regards 
shyu 
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH v2] qemu: read backing chain names from qemu

2015-03-12 Thread Shanzhi Yu
I do meet libvirtd crash sometime when test this patch(I also
met it when test v1 yesterday, but can not reproduce it 100%.)

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffe9d39700 (LWP 25413)]
virJSONValueObjectGetString (object=0x0, key=key@entry=0x7fffe4f72429
filename) at util/virjson.c:1074
1074if (object-type != VIR_JSON_TYPE_OBJECT)
(gdb) t a a bt

Thread 6 (Thread 0x7fffe9d39700 (LWP 25413)):
#0  virJSONValueObjectGetString (object=0x0,
key=key@entry=0x7fffe4f72429 filename) at util/virjson.c:1074
#1  0x7fffe4f2a1f4 in qemuMonitorJSONDiskNameLookupOne
(image=optimized out, top=0x7fffd40013b0,
target=target@entry=0x7fffd40013b0)
at qemu/qemu_monitor_json.c:3901
#2  0x7fffe4f2a1bc in qemuMonitorJSONDiskNameLookupOne
(image=optimized out, top=top@entry=0x7fffdc0fc940,
target=target@entry=0x7fffd40013b0)
at qemu/qemu_monitor_json.c:3898
#3  0x7fffe4f31800 in qemuMonitorJSONDiskNameLookup (mon=optimized
out, device=0x7fffd429cee0 drive-virtio-disk0, top=0x7fffdc0fc940,
target=target@entry=0x7fffd40013b0) at qemu/qemu_monitor_json.c:3963
#4  0x7fffe4f1f87e in qemuMonitorDiskNameLookup (mon=optimized
out, device=optimized out, top=optimized out,
target=target@entry=0x7fffd40013b0)
at qemu/qemu_monitor.c:3475
#5  0x7fffe4f55775 in qemuDomainBlockCommit (dom=optimized out,
path=optimized out, base=optimized out, top=optimized out,
bandwidth=optimized out,
flags=optimized out) at qemu/qemu_driver.c:16937
#6  0x775ff933 in virDomainBlockCommit
(dom=dom@entry=0x7fffd429d630, disk=0x7fffd40010a0 vda, base=0x0,
top=0x0, bandwidth=0, flags=5)
at libvirt-domain.c:10218
#7  0x555736fe in remoteDispatchDomainBlockCommit
(server=optimized out, msg=optimized out, args=0x7fffd429d9c0,
rerr=0x7fffe9d38cb0,
client=optimized out) at remote_dispatch.h:2594
#8  remoteDispatchDomainBlockCommitHelper (server=optimized out,
client=optimized out, msg=optimized out, rerr=0x7fffe9d38cb0,
args=0x7fffd429d9c0,
ret=optimized out) at remote_dispatch.h:2564
#9  0x77653db9 in virNetServerProgramDispatchCall
(msg=0x557d8240, client=0x557ce4a0, server=0x557cc820,
prog=0x557d4a40)
at rpc/virnetserverprogram.c:437
#10 virNetServerProgramDispatch (prog=0x557d4a40,
server=server@entry=0x557cc820, client=0x557ce4a0,
msg=0x557d8240) at rpc/virnetserverprogram.c:307
#11 0x555989d8 in virNetServerProcessMsg (msg=optimized out,
prog=optimized out, client=optimized out, srv=0x557cc820) at
rpc/virnetserver.c:172
#12 virNetServerHandleJob (jobOpaque=optimized out,
opaque=0x557cc820) at rpc/virnetserver.c:193
#13 0x7755ed8e in virThreadPoolWorker
(opaque=opaque@entry=0x557d8370) at util/virthreadpool.c:144
#14 0x7755e72e in virThreadHelper (data=optimized out) at
util/virthread.c:197
#15 0x75de252a in start_thread (arg=0x7fffe9d39700) at
pthread_create.c:310
#16 0x75b1e22d in clone () at
../sysdeps/unix/sysv/linux/x86_64/clone.S:109



On 03/13/2015 04:23 AM, Eric Blake wrote:
 https://bugzilla.redhat.com/show_bug.cgi?id=1199182 documents that
 after a series of disk snapshots into existing destination images,
 followed by active commits of the top image, it is possible for
 qemu 2.2 and earlier to end up tracking a different name for the
 image than what it would have had when opening the chain afresh.
 That is, when starting with the chain 'a - b - c', the name
 associated with 'b' is how it was spelled in the metadata of 'c',
 but when starting with 'a', taking two snapshots into 'a - b - c',
 then committing 'c' back into 'b', the name associated with 'b' is
 now the name used when taking the first snapshot.

 Sadly, older qemu doesn't know how to treat different spellings of
 the same filename as identical files (it uses strcmp() instead of
 checking for the same inode), which means libvirt's attempt to
 commit an image using solely the names learned from qcow2 metadata
 fails with a cryptic:

 error: internal error: unable to execute QEMU command 'block-commit': Top 
 image file /tmp/images/c/../b/b not found

 even though the file exists.  Trying to teach libvirt the rules on
 which name qemu will expect is not worth the effort (besides, we'd
 have to remember it across libvirtd restarts, and track whether a
 file was opened via metadata or via snapshot creation for a given
 qemu process); it is easier to just always directly ask qemu what
 string it expects to see in the first place.

 As a safety valve, we validate that any name returned by qemu
 still maps to the same local file as we have tracked it, so that
 a compromised qemu cannot accidentally cause us to act on an
 incorrect file.

 * src/qemu/qemu_monitor.h (qemuMonitorDiskNameLookup): New
 prototype.
 * src/qemu/qemu_monitor_json.h (qemuMonitorJSONDiskNameLookup):
 Likewise.
 * src/qemu/qemu_monitor.c (qemuMonitorDiskNameLookup): New function.
 * src/qemu/qemu_monitor_json.c 

Re: [libvirt] [PATCH v2] qemu: snapshot: remove the redundant 'if' check

2015-03-04 Thread Shanzhi Yu


On 03/04/2015 09:12 PM, Peter Krempa wrote:
 On Sat, Feb 28, 2015 at 17:51:36 +0800, Shanzhi Yu wrote:
 When the domain's source disk type is network, if source protocol
 is rbd or sheepdog, the 'if().. break' will end the current case,
 which lead to miss check the driver type is raw or qcow2. Libvirt
 will allow to create internal snapshot for a running domain with
 raw format disk which based on rbd storage.

 Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1179533
 Signed-off-by: Shanzhi Yu s...@redhat.com
 ---
  src/qemu/qemu_driver.c | 5 -
  1 file changed, 5 deletions(-)

 diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
 index e282464..544ed82 100644
 --- a/src/qemu/qemu_driver.c
 +++ b/src/qemu/qemu_driver.c
 @@ -13422,11 +13422,6 @@ qemuDomainSnapshotPrepare(virConnectPtr conn,
active)  0)
  goto cleanup;
  
 -if (dom_disk-src-type == VIR_STORAGE_TYPE_NETWORK 
 -(dom_disk-src-protocol == 
 VIR_STORAGE_NET_PROTOCOL_SHEEPDOG ||
 - dom_disk-src-protocol == VIR_STORAGE_NET_PROTOCOL_RBD)) {
 -break;
 -}
 The original intention was apparently that both protocols listed above
 support internal snapshots natively. One problem with that is that while
 they might support doing the snapshot, they don't provide place to store
 the memory data.

 So .. ACK, in the current implementation of internal snapshots we'll
 need to require that the volume is indeed a qcow2 so that metadata can
 be written.

 I'll push the patch shortly.

Thanks for your review.


 Peter

-- 
Regards
shyu

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH v2] qemu: snapshot: remove the redundant 'if' check

2015-02-28 Thread Shanzhi Yu
When the domain's source disk type is network, if source protocol
is rbd or sheepdog, the 'if().. break' will end the current case,
which lead to miss check the driver type is raw or qcow2. Libvirt
will allow to create internal snapshot for a running domain with
raw format disk which based on rbd storage.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1179533
Signed-off-by: Shanzhi Yu s...@redhat.com
---
 src/qemu/qemu_driver.c | 5 -
 1 file changed, 5 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index e282464..544ed82 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -13422,11 +13422,6 @@ qemuDomainSnapshotPrepare(virConnectPtr conn,
   active)  0)
 goto cleanup;
 
-if (dom_disk-src-type == VIR_STORAGE_TYPE_NETWORK 
-(dom_disk-src-protocol == VIR_STORAGE_NET_PROTOCOL_SHEEPDOG 
||
- dom_disk-src-protocol == VIR_STORAGE_NET_PROTOCOL_RBD)) {
-break;
-}
 if (vm-def-disks[i]-src-format  0 
 vm-def-disks[i]-src-format != VIR_STORAGE_FILE_QCOW2) {
 virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-- 
2.1.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] qemu: snapshot: post error when create internal system checkpoint snapshot with rbd backend

2015-02-27 Thread Shanzhi Yu

On 02/19/2015 10:35 PM, Michal Privoznik wrote:
 On 11.02.2015 16:57, Shanzhi Yu wrote:
 When create internel system checkpoint snapshot with source file based
 on rbd backend, libvirt miss to check if the format of source file
 support internal snapshot.

 Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1179533
 Signed-off-by: Shanzhi Yu s...@redhat.com
 ---
  src/qemu/qemu_driver.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)

 diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
 index 26fc6a2..6dd0a5c 100644
 --- a/src/qemu/qemu_driver.c
 +++ b/src/qemu/qemu_driver.c
 @@ -13423,8 +13423,7 @@ qemuDomainSnapshotPrepare(virConnectPtr conn,
  goto cleanup;
  
  if (dom_disk-src-type == VIR_STORAGE_TYPE_NETWORK 
 -(dom_disk-src-protocol == 
 VIR_STORAGE_NET_PROTOCOL_SHEEPDOG ||
 - dom_disk-src-protocol == VIR_STORAGE_NET_PROTOCOL_RBD)) {
 +dom_disk-src-protocol == 
 VIR_STORAGE_NET_PROTOCOL_SHEEPDOG) {
  break;
  }
  if (vm-def-disks[i]-src-format  0 

 This check was introduced in b57e0153. I wonder what has changed since
 than. I'm not that familiar with snapshots nor ceph. But the whole if()
 block seems redundant to me. I mean, whether we know how to create a
 snapshot for given disk is checked a few lines above in
 qemuDomainSnapshotPrepareDiskInternal().
 Therefore I think it can be removed whole, the if() block.

Thanks for review, will try to a v2

 Michal

-- 
Regards
shyu

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] util: make use of VIR_LOCK_SPACE_ACQUIRE_AUTOCREATE in virLockSpaceAcquireResource

2015-02-12 Thread Shanzhi Yu
When create external disk snapshot with virtlock enabled, libvirtd
will hang if flag VIR_LOCK_SPACE_ACQUIRE_AUTOCREATE is missed in
virLockSpaceAcquireResource.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1191901
Signed-off-by: Shanzhi Yu s...@redhat.com
---
 src/util/virlockspace.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/util/virlockspace.c b/src/util/virlockspace.c
index 2366a74..25b4433 100644
--- a/src/util/virlockspace.c
+++ b/src/util/virlockspace.c
@@ -626,8 +626,10 @@ int virLockSpaceAcquireResource(virLockSpacePtr lockspace,
 virMutexLock(lockspace-lock);
 
 if ((res = virHashLookup(lockspace-resources, resname))) {
-if ((res-flags  VIR_LOCK_SPACE_ACQUIRE_SHARED) 
-(flags  VIR_LOCK_SPACE_ACQUIRE_SHARED)) {
+if (((res-flags  VIR_LOCK_SPACE_ACQUIRE_SHARED) 
+(flags  VIR_LOCK_SPACE_ACQUIRE_SHARED)) ||
+((res-flags  VIR_LOCK_SPACE_ACQUIRE_AUTOCREATE) 
+(flags  VIR_LOCK_SPACE_ACQUIRE_AUTOCREATE))){
 
 if (VIR_EXPAND_N(res-owners, res-nOwners, 1)  0)
 goto cleanup;
-- 
1.8.3.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] util: make use of VIR_LOCK_SPACE_ACQUIRE_AUTOCREATE in virLockSpaceAcquireResource

2015-02-12 Thread Shanzhi Yu


On 02/12/2015 07:17 PM, Daniel P. Berrange wrote:

On Thu, Feb 12, 2015 at 07:12:57PM +0800, Shanzhi Yu wrote:

When create external disk snapshot with virtlock enabled, libvirtd
will hang if flag VIR_LOCK_SPACE_ACQUIRE_AUTOCREATE is missed in
virLockSpaceAcquireResource.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1191901
Signed-off-by: Shanzhi Yu s...@redhat.com
---
  src/util/virlockspace.c | 6 --
  1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/util/virlockspace.c b/src/util/virlockspace.c
index 2366a74..25b4433 100644
--- a/src/util/virlockspace.c
+++ b/src/util/virlockspace.c
@@ -626,8 +626,10 @@ int virLockSpaceAcquireResource(virLockSpacePtr lockspace,
  virMutexLock(lockspace-lock);
  
  if ((res = virHashLookup(lockspace-resources, resname))) {

-if ((res-flags  VIR_LOCK_SPACE_ACQUIRE_SHARED) 
-(flags  VIR_LOCK_SPACE_ACQUIRE_SHARED)) {
+if (((res-flags  VIR_LOCK_SPACE_ACQUIRE_SHARED) 
+(flags  VIR_LOCK_SPACE_ACQUIRE_SHARED)) ||
+((res-flags  VIR_LOCK_SPACE_ACQUIRE_AUTOCREATE) 
+(flags  VIR_LOCK_SPACE_ACQUIRE_AUTOCREATE))){

No, this is wrong. If virHashLookup returns a non-NULL entry it
indicates that the lock is already held. It is not valid to
ignore this error if 'autocreate' flag is set, as that would allow
multiple VMs to own the same disk which is exactly the scenario we
are trying to prevent.


Yes. It's really wrong way. Please ignore this.



Regards,
Daniel



--
Regards
shyu

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] qemu: snapshot: post error when create internal system checkpoint snapshot with rbd backend

2015-02-11 Thread Shanzhi Yu
When create internel system checkpoint snapshot with source file based
on rbd backend, libvirt miss to check if the format of source file
support internal snapshot.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1179533
Signed-off-by: Shanzhi Yu s...@redhat.com
---
 src/qemu/qemu_driver.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 26fc6a2..6dd0a5c 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -13423,8 +13423,7 @@ qemuDomainSnapshotPrepare(virConnectPtr conn,
 goto cleanup;
 
 if (dom_disk-src-type == VIR_STORAGE_TYPE_NETWORK 
-(dom_disk-src-protocol == VIR_STORAGE_NET_PROTOCOL_SHEEPDOG 
||
- dom_disk-src-protocol == VIR_STORAGE_NET_PROTOCOL_RBD)) {
+dom_disk-src-protocol == VIR_STORAGE_NET_PROTOCOL_SHEEPDOG) {
 break;
 }
 if (vm-def-disks[i]-src-format  0 
-- 
2.1.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] storage: rbd: Improve the error when start a pool based on non-exist rados object

2015-02-10 Thread Shanzhi Yu


On 02/06/2015 08:55 PM, Ján Tomko wrote:

On Fri, Feb 06, 2015 at 07:45:37PM +0800, Shanzhi Yu wrote:

When start/create a pool based on non-exist rados object, the error will be like
$virsh pool-start p-c
error: Failed to start pool p-c
error: failed to create the RBD IoCTX. Does the pool 'libvirt-pool-clone' 
exist?: No such file or directory

update it to

error: Failed to start pool p-c
error: internal error: failed to create the RBD IoCTX. the rados pool 
'libvirt-pool-clone' is not available

This message is missing the actual error: 'no such file or directory'
returned by rados_ioctx_create. This return value has been added
to the error message by commit 761491eb


Indeed. Just catch that commit


Maybe we could just drop the hint about the pool existence?
error: failed to create the RBD IoCTX: No such file or directory


Would it be better to wrap the error returned by librados? Returning a 
libvirt error will be more friendly to a libvirt user




Jan

Signed-off-by: Shanzhi Yu s...@redhat.com
---
  src/storage/storage_backend_rbd.c | 6 --
  1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/storage/storage_backend_rbd.c 
b/src/storage/storage_backend_rbd.c
index 57182de..98e7fe7 100644
--- a/src/storage/storage_backend_rbd.c
+++ b/src/storage/storage_backend_rbd.c
@@ -236,8 +236,10 @@ static int 
virStorageBackendRBDOpenIoCTX(virStorageBackendRBDStatePtr ptr, virSt
  {
  int r = rados_ioctx_create(ptr-cluster, pool-def-source.name, 
ptr-ioctx);
  if (r  0) {
-virReportSystemError(-r, _(failed to create the RBD IoCTX. Does the pool 
'%s' exist?),
- pool-def-source.name);
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _(failed to create the RBD IoCTX. 
+   the rados pool '%s' is not available),
+   pool-def-source.name);
  }
  return r;
  }
--
2.1.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


--
Regards
shyu

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] qemu: fix crash in migrate when migrateuri do not have a scheme

2015-02-10 Thread Shanzhi Yu


On 02/11/2015 03:41 PM, Luyao Huang wrote:

https://bugzilla.redhat.com/show_bug.cgi?id=1191355

When we migrate a vm with migrateuri option with a uri do not
have scheme like this:

  # virsh migrate test4 --live qemu+ssh://lhuang/system --migrateuri 127.0.0.1

target libvirtd will crashed because uri-scheme is NULL in
qemuMigrationPrepareDirect this line:

  if (STRNEQ(uri-scheme, tcp) 

add a value check before this line.

Signed-off-by: Luyao Huang lhu...@redhat.com
---
  src/qemu/qemu_migration.c | 7 +++
  1 file changed, 7 insertions(+)

diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 879b1bf..5c3b73e 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -3281,6 +3281,13 @@ qemuMigrationPrepareDirect(virQEMUDriverPtr driver,
  if (!(uri = qemuMigrationParseURI(uri_in, well_formed_uri)))
  goto cleanup;
  
+if (uri-scheme == NULL) {

+virReportError(VIR_ERR_INVALID_ARG,
+   _(missing scheme in migration URI: %s),
+   uri_in);
+goto cleanup;
+}
+
  if (STRNEQ(uri-scheme, tcp) 
  STRNEQ(uri-scheme, rdma)) {


Why not just use STRNEQ_NULLABLE instead of STRNEQ directly?

# git diff
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 879b1bf..baca2ed 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -3281,8 +3281,8 @@ qemuMigrationPrepareDirect(virQEMUDriverPtr driver,
 if (!(uri = qemuMigrationParseURI(uri_in, well_formed_uri)))
 goto cleanup;

-if (STRNEQ(uri-scheme, tcp) 
-STRNEQ(uri-scheme, rdma)) {
+if (STRNEQ_NULLABLE(uri-scheme, tcp) 
+STRNEQ_NULLABLE(uri-scheme, rdma)) {


  virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED,


--
Regards
shyu

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] storage: rbd: Improve the error when start a pool based on non-exist rados object

2015-02-06 Thread Shanzhi Yu
When start/create a pool based on non-exist rados object, the error will be like
$virsh pool-start p-c
error: Failed to start pool p-c
error: failed to create the RBD IoCTX. Does the pool 'libvirt-pool-clone' 
exist?: No such file or directory

update it to

error: Failed to start pool p-c
error: internal error: failed to create the RBD IoCTX. the rados pool 
'libvirt-pool-clone' is not available
Signed-off-by: Shanzhi Yu s...@redhat.com
---
 src/storage/storage_backend_rbd.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/storage/storage_backend_rbd.c 
b/src/storage/storage_backend_rbd.c
index 57182de..98e7fe7 100644
--- a/src/storage/storage_backend_rbd.c
+++ b/src/storage/storage_backend_rbd.c
@@ -236,8 +236,10 @@ static int 
virStorageBackendRBDOpenIoCTX(virStorageBackendRBDStatePtr ptr, virSt
 {
 int r = rados_ioctx_create(ptr-cluster, pool-def-source.name, 
ptr-ioctx);
 if (r  0) {
-virReportSystemError(-r, _(failed to create the RBD IoCTX. Does the 
pool '%s' exist?),
- pool-def-source.name);
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _(failed to create the RBD IoCTX. 
+   the rados pool '%s' is not available),
+   pool-def-source.name);
 }
 return r;
 }
-- 
2.1.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] qemu: snapshot: inactive external snapshot can't work after libvirtd restart

2015-01-15 Thread Shanzhi Yu


On 01/14/2015 12:14 AM, John Ferlan wrote:


On 12/06/2014 11:32 AM, Shanzhi Yu wrote:

When create inactive external snapshot, after update disk definitions,
virDomainSaveConfig is needed, if not after restart libvirtd the new snapshot
file definitions in xml will be lost.

Reproduce steps:

1. prepare a shut off guest
$ virsh domstate rhel7  virsh domblklist rhel7
shut off

Target Source

vda/var/lib/libvirt/images/rhel7.img

2. create external disk snapshot
$ virsh snapshot-create rhel7 --disk-only  virsh domblklist rhel7
Domain snapshot 1417882967 created
Target Source

vda/var/lib/libvirt/images/rhel7.1417882967

3. restart libvirtd then check guest source file
$ service  libvirtd restart  virsh domblklist rhel7
Redirecting to /bin/systemctl restart  libvirtd.service
Target Source

vda/var/lib/libvirt/images/rhel7.img

This was first reported by Eric Blake
http://www.redhat.com/archives/libvir-list/2014-December/msg00369.html

Signed-off-by: Shanzhi Yu s...@redhat.com
---
  src/qemu/qemu_driver.c | 3 +++
  1 file changed, 3 insertions(+)


Looks like this one may have been lost in the shuffle prior to the
holidays...

Seems reasonable to me - although I'll wait a bit before pushing just in
case by popping it to the top of the stack again it causes more
discussion...

John


Thanks. I almost forgot it myself.


diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 9152cf5..9f8ea0a 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -12847,6 +12847,9 @@ 
qemuDomainSnapshotCreateInactiveExternal(virQEMUDriverPtr driver,
  goto cleanup;
  }
  defdisk-src-format = snapdisk-src-format;
+
+if (virDomainSaveConfig(cfg-configDir, vm-def)  0)
+goto cleanup;
  }
  }
  



--
Regards
shyu

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] qemu: snapshot: inactive external snapshot can't work after libvirtd restart

2014-12-06 Thread Shanzhi Yu
When create inactive external snapshot, after update disk definitions,
virDomainSaveConfig is needed, if not after restart libvirtd the new snapshot
file definitions in xml will be lost.

Reproduce steps:

1. prepare a shut off guest
$ virsh domstate rhel7  virsh domblklist rhel7
shut off

Target Source

vda/var/lib/libvirt/images/rhel7.img

2. create external disk snapshot
$ virsh snapshot-create rhel7 --disk-only  virsh domblklist rhel7
Domain snapshot 1417882967 created
Target Source

vda/var/lib/libvirt/images/rhel7.1417882967

3. restart libvirtd then check guest source file
$ service  libvirtd restart  virsh domblklist rhel7
Redirecting to /bin/systemctl restart  libvirtd.service
Target Source

vda/var/lib/libvirt/images/rhel7.img

This was first reported by Eric Blake
http://www.redhat.com/archives/libvir-list/2014-December/msg00369.html

Signed-off-by: Shanzhi Yu s...@redhat.com
---
 src/qemu/qemu_driver.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 9152cf5..9f8ea0a 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -12847,6 +12847,9 @@ 
qemuDomainSnapshotCreateInactiveExternal(virQEMUDriverPtr driver,
 goto cleanup;
 }
 defdisk-src-format = snapdisk-src-format;
+
+if (virDomainSaveConfig(cfg-configDir, vm-def)  0)
+goto cleanup;
 }
 }
 
-- 
2.1.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] snapshot-create-as doesn't always work across libvirtd restarts

2014-12-06 Thread Shanzhi Yu


On 12/06/2014 03:33 PM, Eric Blake wrote:

I just found out the hard way that we have a bug in snapshot-create-as,
when I corrupted a guest.  I was testing with an offline domain:

# virsh dumpxml win64 |grep -C1 driver
 disk type='block' device='disk'
   driver name='qemu' type='raw'/
   source dev='/dev/sda4'/
# virsh snapshot-create-as win64 --disk-only --diskspec
hda,file=/var/lib/libvirt/images/win64.qcow2 --no-metadata
Domain snapshot 1417850911 created
# virsh dumpxml win64 |grep -C1 driver
 disk type='block' device='disk'
   driver name='qemu' type='qcow2'/
   source dev='/var/lib/libvirt/images/win64.qcow2'/
# systemctl restart libvirtd
# virsh dumpxml win64 |grep -C1 driver
 disk type='block' device='disk'
   driver name='qemu' type='raw'/
   source dev='/dev/sda4'/

Even though we don't want to save the snapshot metadata, we DO need to
save the XML change.  Otherwise, the restarted libvirtd sees the wrong
disk as the source; worse, if the user started the guest before
restarting libvirtd, they run the risk of accidentally reverting to the
pre-snapshot state and losing all changes they made in the meantime,
perhaps even getting their guest filesystem into an inconsistent state.

I'm out of time to get to a root cause or fix before next week, but
wanted to report it now.  I'm not sure if --no-metadata is essential to
reproducing the bug, or if it happens in all cases.


Hi Eric,
I can reproduce it without --no-metadata option. Can you give the bug 
number if you have file it so that QE can track it
I post a patch 
http://www.redhat.com/archives/libvir-list/2014-December/msg00369.html. 
It works for me after a simple test






--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


--
Regards
shyu

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH] qemu: snapshot: Report better error when create internal snapshot with passthrough devices

2014-12-03 Thread Shanzhi Yu
When create internal system checkpoint snapshot, it will not works if
guest has passthrough devices attached. It will report error:

error: operation failed: Error -22 while writing VM
With this patch, it will report erro:

error: Requested operation is not valid: domain has assigned non-USB host 
devices

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=874418#c19
---
 src/qemu/qemu_driver.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 5dc62b0..0fdee26 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -12902,6 +12902,9 @@ qemuDomainSnapshotCreateActiveInternal(virConnectPtr 
conn,
 }
 }
 
+if (!qemuMigrationIsAllowed(driver, vm, vm-def, false, false))
+goto cleanup;
+
 if (qemuDomainObjEnterMonitorAsync(driver, vm,
QEMU_ASYNC_JOB_SNAPSHOT)  0) {
 resume = false;
-- 
1.8.3.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] virsh: vol-upload disallow negative offset

2014-12-02 Thread Shanzhi Yu
In commit 570d0f, it should diable negative offset both in cmdVolDownload and
cmdVolUpload according the description, while it really didn't in cmdVolUpload
Disable it in this patch

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1087104
Signed-off-by: Shanzhi Yu s...@redhat.com
---
 tools/virsh-volume.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/virsh-volume.c b/tools/virsh-volume.c
index 27bd81d..d585ee2 100644
--- a/tools/virsh-volume.c
+++ b/tools/virsh-volume.c
@@ -677,13 +677,13 @@ cmdVolUpload(vshControl *ctl, const vshCmd *cmd)
 const char *name = NULL;
 unsigned long long offset = 0, length = 0;
 
-if (vshCommandOptULongLongWrap(cmd, offset, offset)  0) {
-vshError(ctl, _(Unable to parse integer));
+if (vshCommandOptULongLong(cmd, offset, offset)  0) {
+vshError(ctl, _(Unable to parse offset value));
 return false;
 }
 
 if (vshCommandOptULongLongWrap(cmd, length, length)  0) {
-vshError(ctl, _(Unable to parse integer));
+vshError(ctl, _(Unable to parse length value));
 return false;
 }
 
-- 
2.1.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] qemu: add port check for iscsi host when disk type is network

2014-11-13 Thread Shanzhi Yu
For network type disk, host port is not checked when source protocol is
iscsi, so the error is not sure when with invalid port. If pass -1 to port
the error  will be
error: Failed to start domain rh6-i
error: An error occurred, but the cause is unknown

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1163553
Signed-off-by: Shanzhi Yu s...@redhat.com
---
 src/qemu/qemu_command.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index f674ba9..f806225 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3016,6 +3016,12 @@ qemuBuildNetworkDriveURI(int protocol,
 case VIR_STORAGE_NET_PROTOCOL_FTPS:
 case VIR_STORAGE_NET_PROTOCOL_TFTP:
 case VIR_STORAGE_NET_PROTOCOL_ISCSI:
+if (STRNEQ_NULLABLE(hosts-port,3260)) {
+virReportError(VIR_ERR_INTERNAL_ERROR, %s,
+   _(expected port for iscsi host should be 
3260));
+goto cleanup;
+}
+
 case VIR_STORAGE_NET_PROTOCOL_GLUSTER:
 if (nhosts != 1) {
 virReportError(VIR_ERR_INTERNAL_ERROR,
-- 
1.9.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] qemu: add port check for iscsi host when disk type is network

2014-11-13 Thread Shanzhi Yu


On 11/13/2014 05:42 PM, Peter Krempa wrote:

On 11/13/14 10:28, Shanzhi Yu wrote:

For network type disk, host port is not checked when source protocol is
iscsi, so the error is not sure when with invalid port. If pass -1 to port
the error  will be
error: Failed to start domain rh6-i
error: An error occurred, but the cause is unknown

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1163553
Signed-off-by: Shanzhi Yu s...@redhat.com
---
  src/qemu/qemu_command.c | 6 ++
  1 file changed, 6 insertions(+)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index f674ba9..f806225 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3016,6 +3016,12 @@ qemuBuildNetworkDriveURI(int protocol,
  case VIR_STORAGE_NET_PROTOCOL_FTPS:
  case VIR_STORAGE_NET_PROTOCOL_TFTP:
  case VIR_STORAGE_NET_PROTOCOL_ISCSI:
+if (STRNEQ_NULLABLE(hosts-port,3260)) {
+virReportError(VIR_ERR_INTERNAL_ERROR, %s,
+   _(expected port for iscsi host should be 
3260));
+goto cleanup;
+}

Um? this would forbid to use any other port than 3260 for any of the
protocols stated above. That doesn't make sense neither for iSCSI nor
for the other ones.

The code should make sure that the port is in range 0,65536 and don't
force to use a certain port. Ohterwise we wouldn't need a port field.


How about make a check for every protocols above, eg FTP, HTTP. As 
known, different protocol use certain port, if just make sure

the port is in range 0.65535,  error info may be like

error: Failed to start domain rh6-i
error: internal error: process exited while connecting to monitor: 
2014-11-13T10:06:57.112170Z qemu-system-x86_64: -drive 
file=ftp://10.66.6.111:100/mnt/nfs/rhel6.img,if=none,id=drive-virtio-disk0,format=raw,cache=none: 
could not open disk image ftp://10.66.6.111:100/mnt/nfs/rhel6.img: curl 
block device does not support writes





+
  case VIR_STORAGE_NET_PROTOCOL_GLUSTER:
  if (nhosts != 1) {
  virReportError(VIR_ERR_INTERNAL_ERROR,


NACK to this approach.

Peter



--
Regards
shyu

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] qemu: add port check for iscsi host when disk type is network

2014-11-13 Thread Shanzhi Yu


On 11/13/2014 06:21 PM, Peter Krempa wrote:

On 11/13/14 11:17, Shanzhi Yu wrote:

On 11/13/2014 05:42 PM, Peter Krempa wrote:

On 11/13/14 10:28, Shanzhi Yu wrote:

For network type disk, host port is not checked when source protocol is
iscsi, so the error is not sure when with invalid port. If pass -1 to
port
the error  will be
error: Failed to start domain rh6-i
error: An error occurred, but the cause is unknown

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1163553
Signed-off-by: Shanzhi Yu s...@redhat.com
---
   src/qemu/qemu_command.c | 6 ++
   1 file changed, 6 insertions(+)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index f674ba9..f806225 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3016,6 +3016,12 @@ qemuBuildNetworkDriveURI(int protocol,
   case VIR_STORAGE_NET_PROTOCOL_FTPS:
   case VIR_STORAGE_NET_PROTOCOL_TFTP:
   case VIR_STORAGE_NET_PROTOCOL_ISCSI:
+if (STRNEQ_NULLABLE(hosts-port,3260)) {
+virReportError(VIR_ERR_INTERNAL_ERROR, %s,
+   _(expected port for iscsi host
should be 3260));
+goto cleanup;
+}

Um? this would forbid to use any other port than 3260 for any of the
protocols stated above. That doesn't make sense neither for iSCSI nor
for the other ones.

The code should make sure that the port is in range 0,65536 and don't
force to use a certain port. Ohterwise we wouldn't need a port field.

How about make a check for every protocols above, eg FTP, HTTP. As
known, different protocol use certain port, if just make sure

They use certain ports as a default. That doesn't mean the admin can't
configure to run the service at a different port.


Yes, I see.



the port is in range 0.65535,  error info may be like

error: Failed to start domain rh6-i
error: internal error: process exited while connecting to monitor:
2014-11-13T10:06:57.112170Z qemu-system-x86_64: -drive
file=ftp://10.66.6.111:100/mnt/nfs/rhel6.img,if=none,id=drive-virtio-disk0,format=raw,cache=none:
could not open disk image ftp://10.66.6.111:100/mnt/nfs/rhel6.img: curl
block device does not support writes

You didn't understand the error message apparently. The message says
that the FTP backend in qemu is supported only with read-only disks, not
that port 100 is invalid.

I misunderstand the error info. Thanks for explanation



Peter




--
Regards
shyu

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH v2] qemu: add port check for host when disk type is network

2014-11-13 Thread Shanzhi Yu
For network type disk, host port is not checked when start a guest,
so the error may be unclear when with invalid port. If pass -1 to port
the error will be
error: Failed to start domain rh6-i
error: An error occurred, but the cause is unknown
So make a check to make sure the port range from 0 to 65536

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1163553
Signed-off-by: Shanzhi Yu s...@redhat.com
---
 src/qemu/qemu_command.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index f674ba9..66082e1 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3016,6 +3016,18 @@ qemuBuildNetworkDriveURI(int protocol,
 case VIR_STORAGE_NET_PROTOCOL_FTPS:
 case VIR_STORAGE_NET_PROTOCOL_TFTP:
 case VIR_STORAGE_NET_PROTOCOL_ISCSI:
+if (VIR_ALLOC(uri)  0)
+goto cleanup;
+
+if (qemuNetworkDriveGetPort(protocol, hosts-port)  0 ||
+qemuNetworkDriveGetPort(protocol, hosts-port)  65536) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _(port should be in range 0 to 65536 for '%s' 
host),
+   virStorageNetProtocolTypeToString(protocol));
+
+goto cleanup;
+}
+
 case VIR_STORAGE_NET_PROTOCOL_GLUSTER:
 if (nhosts != 1) {
 virReportError(VIR_ERR_INTERNAL_ERROR,
-- 
1.9.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] uitl: use if and only if instead of iff in some comments

2014-10-28 Thread Shanzhi Yu
From wiki In writing, phrases commonly used, with debatable propriety.
In logic formulae, logical symbols are used instead of these phrases
In some comments, we use if and only if, so instead the logical sysbols
with phrases in case someone mistaking it as a wrong spelling of if

Signed-off-by: Shanzhi Yu s...@redhat.com
---
 src/util/virhash.c   | 2 +-
 src/util/virstring.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/util/virhash.c b/src/util/virhash.c
index e3c1880..e3bf1d3 100644
--- a/src/util/virhash.c
+++ b/src/util/virhash.c
@@ -65,7 +65,7 @@ struct _virHashTable {
 uint32_t seed;
 size_t size;
 size_t nbElems;
-/* True iff we are iterating over hash entries. */
+/* True if and only if we are iterating over hash entries. */
 bool iterating;
 /* Pointer to the current entry during iteration. */
 virHashEntryPtr current;
diff --git a/src/util/virstring.c b/src/util/virstring.c
index 3dad9dd..974005d 100644
--- a/src/util/virstring.c
+++ b/src/util/virstring.c
@@ -519,7 +519,7 @@ virStrncpy(char *dest, const char *src, size_t n, size_t 
destbytes)
 return NULL;
 
 ret = strncpy(dest, src, n);
-/* strncpy NULL terminates iff the last character is \0.  Therefore
+/* strncpy NULL terminates if and only if the last character is \0.  
Therefore
  * force the last byte to be \0
  */
 dest[n] = '\0';
-- 
1.9.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] uitl: use if and only if instead of iff in some comments

2014-10-28 Thread Shanzhi Yu


On 10/28/2014 10:17 PM, Eric Blake wrote:

On 10/28/2014 08:00 AM, Shanzhi Yu wrote:

From wiki In writing, phrases commonly used, with debatable propriety.
In logic formulae, logical symbols are used instead of these phrases
In some comments, we use if and only if, so instead the logical sysbols
with phrases in case someone mistaking it as a wrong spelling of if

I don't buy it.  It's not worth applying, in my mind.

Furthermore, any patch that tries to fix typos while itself having a
typo (s/uitl/util/ in the subject) is suspect.

shame on me ...

NACK unless anyone else speaks up strongly in favor of it.




--
Regards
shyu

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] util: fix libvirtd crash caused by virStorageNetHostTransportTypeFromString

2014-10-27 Thread Shanzhi Yu


On 10/25/2014 03:12 AM, Eric Blake wrote:

On 10/24/2014 01:01 PM, Shanzhi Yu wrote:

When split uri-scheme into two strings with +, the second one will be

s/split/splitting/


rdma://server/.., pass it to virStorageNetHostTransportTypeFromString
will lead libvirtd crash. So a second virStringSplit call is needed.

Can you show the FULL string that is being passed into this function,
and not just the string after the first split on '+'?  That is, showing
an easy formula of how to reproduce the bug makes it easier to know if
the solution is right.


Seem the solution is not right. I misunderstand uri-scheme as 
gluster+tcp://NetHostIP/path/to/volume

The scheme should be gluster+tcp or gluster+rdma ?
..

if (!(uri = virURIParse(path))) {
virReportError(VIR_ERR_INTERNAL_ERROR,
   _(failed to parse backing file location '%s'),
   path);
goto cleanup;
}

if (!(scheme = virStringSplit(uri-scheme, +, 2)))
goto cleanup;
..

But it is easy to reproduce this crash

Steps:

1) Create a volume with gluster+tcp or gluster+rmda as backend
# qemu-img create -f qcow2 /var/lib/libvirt/images/tcp.img -b 
gluster+tcp://10.66.6.111/gluster-vol1/rhel65.img -o backing_fmt=raw 1G
Formatting '/var/lib/libvirt/images/tcp.img', fmt=qcow2 size=1073741824 
backing_file='gluster+tcp://10.66.6.111/gluster-vol1/rhel65.img' 
backing_fmt='raw' encryption=off cluster_size=65536 lazy_refcounts=off


2) Refresh pool default (target pach /var/lib/libvirt/images)
# virsh pool-refresh default

Libvirtd will crash

..
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7f5df5e4d700 (LWP 23916)]
virStorageSourceParseBackingURI (path=optimized out, 
src=0x7f5de0009130) at util/virstoragefile.c:2126
2126(src-hosts-transport = 
virStorageNetHostTransportTypeFromString(scheme[1]))  0) {

(gdb)

..





Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1156288

You have to assume that not everyone will click through this link.


Signed-off-by: Shanzhi Yu s...@redhat.com
---
  src/util/virstoragefile.c | 3 +++
  1 file changed, 3 insertions(+)

diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index 960aa23..795c188 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -2144,6 +2144,9 @@ virStorageSourceParseBackingURI(virStorageSourcePtr src,
  goto cleanup;
  }
  
+if (!(scheme = virStringSplit(scheme[1], :, 2)))

Ouch. Memory leak.  You are overwriting the contents of malloc'd scheme
with a new pointer.  You'll need to send a v2.


As talk before, seem the solution is wrong. But I do escape the crash 
with below patch


diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index 960aa23..a8373af 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -2124,6 +2124,7 @@ 
virStorageSourceParseBackingURI(virStorageSourcePtr src,

 {
 virURIPtr uri = NULL;
 char **scheme = NULL;
+char **scheme1 = NULL;
 int ret = -1;

 if (!(uri = virURIParse(path))) {
@@ -2144,11 +2145,14 @@ 
virStorageSourceParseBackingURI(virStorageSourcePtr src,

 goto cleanup;
 }

-if (scheme[1] 
-(src-hosts-transport = 
virStorageNetHostTransportTypeFromString(scheme[1])) 

+if (scheme[1]  !(scheme1 = virStringSplit(scheme[1], :, 2)))
+goto cleanup;
+
+if (scheme1[1] 
+(src-hosts-transport = 
virStorageNetHostTransportTypeFromString(scheme1[1]))

 virReportError(VIR_ERR_INTERNAL_ERROR,
_(invalid protocol transport type '%s'),
-   scheme[1]);
+   scheme1[1]);
 goto cleanup;
 }

@@ -2201,6 +2205,8 @@ 
virStorageSourceParseBackingURI(virStorageSourcePtr src,

  cleanup:
 virURIFree(uri);
 virStringFreeList(scheme);
+if (!scheme1)
+virStringFreeList(scheme1);
 return ret;
 }




+goto cleanup;
+
  if (scheme[1] 
  (src-hosts-transport = 
virStorageNetHostTransportTypeFromString(scheme[1]))  0) {
  virReportError(VIR_ERR_INTERNAL_ERROR,



--
Regards
shyu

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] vbox: network: make sure driver not be NULL in virRegisterNetworkDriver

2014-10-24 Thread Shanzhi Yu
libvirtd will report below error if does not make sure driver not be NULL
in virRegisterNetworkDriver

$ libvirtd
2014-10-24 09:24:36.443+: 28876: info : libvirt version: 1.2.10
2014-10-24 09:24:36.443+: 28876: error : virRegisterNetworkDriver:549 : 
driver in virRegisterNetworkDriver must not be NULL
2014-10-24 09:24:36.443+: 28876: error : virDriverLoadModule:99 : Failed 
module registration vboxNetworkRegister

Signed-off-by: Shanzhi Yu s...@redhat.com
---
 src/vbox/vbox_driver.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/vbox/vbox_driver.c b/src/vbox/vbox_driver.c
index 743a488..ff69069 100644
--- a/src/vbox/vbox_driver.c
+++ b/src/vbox/vbox_driver.c
@@ -152,7 +152,7 @@ int vboxNetworkRegister(void)
 if (VBoxCGlueInit(uVersion) == 0)
 networkDriver = vboxGetNetworkDriver(uVersion);
 
-if (virRegisterNetworkDriver(networkDriver)  0)
+if ((networkDriver != NULL)  (virRegisterNetworkDriver(networkDriver)  
0)) 
 return -1;
 return 0;
 }
-- 
1.9.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] vbox: network: make sure driver not be NULL in virRegisterNetworkDriver

2014-10-24 Thread Shanzhi Yu


On 10/24/2014 10:52 PM, Daniel P. Berrange wrote:

On Fri, Oct 24, 2014 at 08:47:47AM -0600, Eric Blake wrote:

On 10/24/2014 03:31 AM, Shanzhi Yu wrote:

libvirtd will report below error if does not make sure driver not be NULL
in virRegisterNetworkDriver

$ libvirtd
2014-10-24 09:24:36.443+: 28876: info : libvirt version: 1.2.10
2014-10-24 09:24:36.443+: 28876: error : virRegisterNetworkDriver:549 : 
driver in virRegisterNetworkDriver must not be NULL
2014-10-24 09:24:36.443+: 28876: error : virDriverLoadModule:99 : Failed 
module registration vboxNetworkRegister

Signed-off-by: Shanzhi Yu s...@redhat.com
---
  src/vbox/vbox_driver.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/vbox/vbox_driver.c b/src/vbox/vbox_driver.c
index 743a488..ff69069 100644
--- a/src/vbox/vbox_driver.c
+++ b/src/vbox/vbox_driver.c
@@ -152,7 +152,7 @@ int vboxNetworkRegister(void)
  if (VBoxCGlueInit(uVersion) == 0)
  networkDriver = vboxGetNetworkDriver(uVersion);
  
-if (virRegisterNetworkDriver(networkDriver)  0)

+if ((networkDriver != NULL)  (virRegisterNetworkDriver(networkDriver)  
0))

Over-parenthesized.  Sufficient to write:

if (networkDriver  virRegisterNetworkDriver(networkDriver)  0)

ACK to this.


Or did you botch the logic, and really mean:

if (!networkDriver || virRegisterNetworkDriver(networkDriver)  0)

Furthermore, Dan's recent patch series will probably overhaul all of
this anyways, so it may be easier to just wait for his patches to land.


Thanks for your review. I mean the  not ||.


No, the logic in the patch is correct. We don't want an error if the
networkDriver is NULL. We just want to continue running without
any error in that case.

We should push this now because we'll want to cherry pick it to stable
branches.


Regards,
Daniel


--
Regards
shyu

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] util: fix libvirtd crash caused by virStorageNetHostTransportTypeFromString

2014-10-24 Thread Shanzhi Yu
When split uri-scheme into two strings with +, the second one will be
rdma://server/.., pass it to virStorageNetHostTransportTypeFromString
will lead libvirtd crash. So a second virStringSplit call is needed.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1156288
Signed-off-by: Shanzhi Yu s...@redhat.com
---
 src/util/virstoragefile.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index 960aa23..795c188 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -2144,6 +2144,9 @@ virStorageSourceParseBackingURI(virStorageSourcePtr src,
 goto cleanup;
 }
 
+if (!(scheme = virStringSplit(scheme[1], :, 2)))
+goto cleanup;
+
 if (scheme[1] 
 (src-hosts-transport = 
virStorageNetHostTransportTypeFromString(scheme[1]))  0) {
 virReportError(VIR_ERR_INTERNAL_ERROR,
-- 
1.9.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] qemu: add capability probing for block-stream

2014-10-24 Thread Shanzhi Yu

Ping?

On 09/16/2014 01:06 PM, Shanzhi Yu wrote:

Since block-stream is not supported on qemu-kvm, so libvirt should
post more accurate error info when do blockpull with qemu-kvm but
not Command 'block-stream' is not found

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1140981
Signed-off-by: Shanzhi Yu s...@redhat.com
---
  src/qemu/qemu_capabilities.c |  2 ++
  src/qemu/qemu_capabilities.h |  1 +
  src/qemu/qemu_driver.c   | 13 +
  3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 81ada48..5674f4f 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -269,6 +269,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
  
splash-timeout, /* 175 */

iothread,
+  block-stream,
  );
  
  
@@ -1426,6 +1427,7 @@ struct virQEMUCapsStringFlags virQEMUCapsCommands[] = {

  { query-spice, QEMU_CAPS_SPICE },
  { query-kvm, QEMU_CAPS_KVM },
  { block-commit, QEMU_CAPS_BLOCK_COMMIT },
+{ block-stream, QEMU_CAPS_BLOCK_STREAM },
  { query-vnc, QEMU_CAPS_VNC },
  { drive-mirror, QEMU_CAPS_DRIVE_MIRROR },
  { blockdev-snapshot-sync, QEMU_CAPS_DISK_SNAPSHOT },
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 0980c00..6701965 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -216,6 +216,7 @@ typedef enum {
  QEMU_CAPS_RTC_RESET_REINJECTION = 174, /* rtc-reset-reinjection monitor 
command */
  QEMU_CAPS_SPLASH_TIMEOUT = 175, /* -boot splash-time */
  QEMU_CAPS_OBJECT_IOTHREAD= 176, /* -object iothread */
+QEMU_CAPS_BLOCK_STREAM   = 177, /* block-stream */
  
  QEMU_CAPS_LAST,   /* this must always be the last item */

  } virQEMUCapsFlags;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 73edda3..b38bc91 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -14980,15 +14980,12 @@ qemuDomainBlockJobImpl(virDomainObjPtr vm,
  virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s,
 _(block jobs not supported with this QEMU binary));
  goto cleanup;
-} else if (base) {
-virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s,
-   _(partial block pull not supported with this 
- QEMU binary));
-goto cleanup;
-} else if (mode == BLOCK_JOB_PULL  bandwidth) {
+}
+
+if (mode == BLOCK_JOB_PULL 
+!(virQEMUCapsGet(priv-qemuCaps, QEMU_CAPS_BLOCK_STREAM))){
  virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s,
-   _(setting bandwidth at start of block pull not 
- supported with this QEMU binary));
+   _(block pull is not supported with this QEMU binary));
  goto cleanup;
  }
  


--
Regards
shyu

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] virsh: Improve the job type reported of virsh cmd blockcommit

2014-10-23 Thread Shanzhi Yu
When begin a blockcommit job(active) with virsh, it will report
Block Commit started(it really donesn't matter much), but for
more preciese it should report Active Block Commit started

Signed-off-by: Shanzhi Yu s...@redhat.com
---
 tools/virsh-domain.c | 12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 94ae3d3..3416e31 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -1723,9 +1723,15 @@ cmdBlockCommit(vshControl *ctl, const vshCmd *cmd)
 goto cleanup;
 
 if (!blocking) {
-vshPrint(ctl, %s, _(Block Commit started));
-ret = true;
-goto cleanup;
+if (active) {
+vshPrint(ctl, %s, _(Active Block Commit started));
+ret = true;
+goto cleanup;
+} else {
+vshPrint(ctl, %s, _(Block Commit started));
+ret = true;
+goto cleanup;
+}
 }
 
 while (blocking) {
-- 
1.9.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH 2/3] qemu: save domain status after set network interface's bandwidth parameters

2014-10-06 Thread Shanzhi Yu


- Original Message -
| From: Martin Kletzander mklet...@redhat.com
| To: Shanzhi Yu s...@redhat.com
| Cc: libvir-list@redhat.com
| Sent: Monday, October 6, 2014 5:43:13 PM
| Subject: Re: [libvirt] [PATCH 2/3] qemu: save domain status after set network 
interface's bandwidth parameters
| 
| On Mon, Sep 29, 2014 at 06:49:34PM +0800, Shanzhi Yu wrote:
| After set network interface's bandwidth for running domain, save the change
| into live xml is needed to survive restarting the libvirtd, same story with
| bug 1146511, meanwhile add call qemuDomainObjBeginJob/qemuDomainObjEndJob
| in qemuDomainSetInterfaceParameters
| 
| Signed-off-by: Shanzhi Yu s...@redhat.com
| ---
|  src/qemu/qemu_driver.c | 28 +++-
|  1 file changed, 19 insertions(+), 9 deletions(-)
| 
| 
| Patch looks fine, but doesn't apply to current master, could you
| rebase the series and resend it, please?

Martin,
Thanks for your review, I will resend it.

| 
| Martin
| 

-- 
Regards
shyu

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCHv2 3/3] qemu: save domain status after set domain's numa parameters

2014-10-06 Thread Shanzhi Yu
After set domain's numa parameters for running domain, save the change,
save the change into live xml is needed to survive restarting the libvirtd,
same story with bug 1146511; meanwihle add call
qemuDomainObjBeginJob/qemuDomainObjEndJob in qemuDomainSetNumaParameters

Signed-off-by: Shanzhi Yu s...@redhat.com
---
 src/qemu/qemu_driver.c | 30 --
 1 file changed, 20 insertions(+), 10 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 188b4f5..ead53ad 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -8986,15 +8986,18 @@ qemuDomainSetNumaParameters(virDomainPtr dom,
 if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
 goto cleanup;
 
+if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY)  0)
+goto cleanup;
+
 if (virDomainLiveConfigHelperMethod(caps, driver-xmlopt, vm, flags,
 persistentDef)  0)
-goto cleanup;
+goto endjob;
 
 if (flags  VIR_DOMAIN_AFFECT_LIVE) {
 if (!virCgroupHasController(priv-cgroup, 
VIR_CGROUP_CONTROLLER_CPUSET)) {
 virReportError(VIR_ERR_OPERATION_INVALID, %s,
_(cgroup cpuset controller is not mounted));
-goto cleanup;
+goto endjob;
 }
 }
 
@@ -9007,18 +9010,18 @@ qemuDomainSetNumaParameters(virDomainPtr dom,
 if (mode  0 || mode = VIR_DOMAIN_NUMATUNE_MEM_LAST) {
 virReportError(VIR_ERR_INVALID_ARG,
_(unsupported numatune mode: '%d'), mode);
-goto cleanup;
+goto endjob;
 }
 
 } else if (STREQ(param-field, VIR_DOMAIN_NUMA_NODESET)) {
 if (virBitmapParse(param-value.s, 0, nodeset,
VIR_DOMAIN_CPUMASK_LEN)  0)
-goto cleanup;
+goto endjob;
 
 if (virBitmapIsAllClear(nodeset)) {
 virReportError(VIR_ERR_OPERATION_INVALID, %s,
_(Invalid nodeset for numatune));
-goto cleanup;
+goto endjob;
 }
 }
 }
@@ -9028,18 +9031,21 @@ qemuDomainSetNumaParameters(virDomainPtr dom,
 virDomainNumatuneGetMode(vm-def-numatune, -1) != mode) {
 virReportError(VIR_ERR_OPERATION_INVALID, %s,
_(can't change numatune mode for running domain));
-goto cleanup;
+goto endjob;
 }
 
 if (nodeset 
 qemuDomainSetNumaParamsLive(vm, caps, nodeset)  0)
-goto cleanup;
+goto endjob;
 
 if (virDomainNumatuneSet(vm-def-numatune,
  vm-def-placement_mode ==
  VIR_DOMAIN_CPU_PLACEMENT_MODE_STATIC,
  -1, mode, nodeset)  0)
-goto cleanup;
+goto endjob;
+
+if (virDomainSaveStatus(driver-xmlopt, cfg-stateDir, vm)  0)
+goto endjob;
 }
 
 if (flags  VIR_DOMAIN_AFFECT_CONFIG) {
@@ -9047,14 +9053,18 @@ qemuDomainSetNumaParameters(virDomainPtr dom,
  persistentDef-placement_mode ==
  VIR_DOMAIN_CPU_PLACEMENT_MODE_STATIC,
  -1, mode, nodeset)  0)
-goto cleanup;
+goto endjob;
 
 if (virDomainSaveConfig(cfg-configDir, persistentDef)  0)
-goto cleanup;
+goto endjob;
 }
 
 ret = 0;
 
+ endjob:
+if (!qemuDomainObjEndJob(driver, vm))
+vm = NULL;
+
  cleanup:
 virBitmapFree(nodeset);
 if (vm)
-- 
1.9.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCHv2 0/3] Save domain satus after change some parameters

2014-10-06 Thread Shanzhi Yu
Related bug: https://bugzilla.redhat.com/show_bug.cgi?id=1146511

Also add BeginJob/EndJob in qemuDomainSetBlkioParameters,
qemuDomainSetInterfaceParameters,qemuDomainSetNumaParameters


Shanzhi Yu (3):
  qemu: save domain status after set the blkio parameters
  qemu: call qemuDomainObjBeginJob/qemuDomainObjEndJob in
qemuDomainSetInterfaceParameters
  qemu: save domain status after set domain's numa parameters

 src/qemu/qemu_driver.c | 76 ++
 1 file changed, 52 insertions(+), 24 deletions(-)

-- 
1.9.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCHv2 1/3] qemu: save domain status after set the blkio parameters

2014-10-06 Thread Shanzhi Yu
After set the blkio parameters for running domain, save the change into
live xml is needed to survive restarting the libvirtd, same story with
bug 1146511, meanwhile add call qemuDomainObjBeginJob/qemuDomainObjEndJob
in qemuDomainSetBlkioParameters

Signed-off-by: Shanzhi Yu s...@redhat.com
---
 src/qemu/qemu_driver.c | 16 +---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index d111ccd..37d1a86 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -7992,15 +7992,18 @@ qemuDomainSetBlkioParameters(virDomainPtr dom,
 if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
 goto cleanup;
 
+if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY)  0)
+goto cleanup;
+
 if (virDomainLiveConfigHelperMethod(caps, driver-xmlopt, vm, flags,
 persistentDef)  0)
-goto cleanup;
+goto endjob;
 
 if (flags  VIR_DOMAIN_AFFECT_LIVE) {
 if (!virCgroupHasController(priv-cgroup, 
VIR_CGROUP_CONTROLLER_BLKIO)) {
 virReportError(VIR_ERR_OPERATION_INVALID, %s,
_(blkio cgroup isn't mounted));
-goto cleanup;
+goto endjob;
 }
 }
 
@@ -8093,9 +8096,12 @@ qemuDomainSetBlkioParameters(virDomainPtr dom,
 VIR_FREE(devices);
 }
 }
+
+if (virDomainSaveStatus(driver-xmlopt, cfg-stateDir, vm)  0)
+goto endjob;
 }
 if (ret  0)
-goto cleanup;
+goto endjob;
 if (flags  VIR_DOMAIN_AFFECT_CONFIG) {
 /* Clang can't see that if we get here, persistentDef was set.  */
 sa_assert(persistentDef);
@@ -8133,6 +8139,10 @@ qemuDomainSetBlkioParameters(virDomainPtr dom,
 ret = -1;
 }
 
+ endjob:
+if (!qemuDomainObjEndJob(driver, vm))
+vm = NULL;
+
  cleanup:
 if (vm)
 virObjectUnlock(vm);
-- 
1.9.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCHv2 2/3] qemu: call qemuDomainObjBeginJob/qemuDomainObjEndJob in qemuDomainSetInterfaceParameters

2014-10-06 Thread Shanzhi Yu
add call qemuDomainObjBeginJob/qemuDomainObjEndJob in
qemuDomainSetInterfaceParameters

Signed-off-by: Shanzhi Yu s...@redhat.com
---
 src/qemu/qemu_driver.c | 30 +++---
 1 file changed, 19 insertions(+), 11 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 37d1a86..188b4f5 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -10139,16 +10139,19 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
 if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
 goto cleanup;
 
+if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY)  0)
+goto cleanup;
+
 if (virDomainLiveConfigHelperMethod(caps, driver-xmlopt, vm, flags,
 persistentDef)  0)
-goto cleanup;
+goto endjob;
 
 if (flags  VIR_DOMAIN_AFFECT_LIVE) {
 net = virDomainNetFind(vm-def, device);
 if (!net) {
 virReportError(VIR_ERR_INVALID_ARG,
_(Can't find device %s), device);
-goto cleanup;
+goto endjob;
 }
 }
 if (flags  VIR_DOMAIN_AFFECT_CONFIG) {
@@ -10156,14 +10159,14 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
 if (!persistentNet) {
 virReportError(VIR_ERR_INVALID_ARG,
_(Can't find device %s), device);
-goto cleanup;
+goto endjob;
 }
 }
 
 if ((VIR_ALLOC(bandwidth)  0) ||
 (VIR_ALLOC(bandwidth-in)  0) ||
 (VIR_ALLOC(bandwidth-out)  0))
-goto cleanup;
+goto endjob;
 
 for (i = 0; i  nparams; i++) {
 virTypedParameterPtr param = params[i];
@@ -10197,7 +10200,7 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
 
 if (flags  VIR_DOMAIN_AFFECT_LIVE) {
 if (VIR_ALLOC(newBandwidth)  0)
-goto cleanup;
+goto endjob;
 
 /* virNetDevBandwidthSet() will clear any previous value of
  * bandwidth parameters, so merge with old bandwidth parameters
@@ -10205,7 +10208,7 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
 if (bandwidth-in ||
 (!inboundSpecified  net-bandwidth  net-bandwidth-in)) {
 if (VIR_ALLOC(newBandwidth-in)  0)
-goto cleanup;
+goto endjob;
 
 memcpy(newBandwidth-in,
bandwidth-in ? bandwidth-in : net-bandwidth-in,
@@ -10214,7 +10217,7 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
 if (bandwidth-out ||
 (!outboundSpecified  net-bandwidth  net-bandwidth-out)) {
 if (VIR_ALLOC(newBandwidth-out)  0)
-goto cleanup;
+goto endjob;
 
 memcpy(newBandwidth-out,
bandwidth-out ? bandwidth-out : net-bandwidth-out,
@@ -10222,7 +10225,7 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
 }
 
 if (virNetDevBandwidthSet(net-ifname, newBandwidth, false)  0)
-goto cleanup;
+goto endjob;
 
 virNetDevBandwidthFree(net-bandwidth);
 if (newBandwidth-in || newBandwidth-out) {
@@ -10236,11 +10239,11 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
 virNetDevBandwidthFree(net-data.network.actual-bandwidth);
 if (virNetDevBandwidthCopy(net-data.network.actual-bandwidth,
net-bandwidth)  0)
-goto cleanup;
+goto endjob;
 }
 
 if (virDomainSaveStatus(driver-xmlopt, cfg-stateDir, vm)  0)
-goto cleanup;
+goto endjob;
 }
 
 if (flags  VIR_DOMAIN_AFFECT_CONFIG) {
@@ -10265,10 +10268,15 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
 }
 
 if (virDomainSaveConfig(cfg-configDir, persistentDef)  0)
-goto cleanup;
+goto endjob;
 }
 
 ret = 0;
+
+ endjob:
+if (!qemuDomainObjEndJob(driver, vm))
+vm = NULL;
+
  cleanup:
 virNetDevBandwidthFree(bandwidth);
 virNetDevBandwidthFree(newBandwidth);
-- 
1.9.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] snapshot: conf: Forbid using same file as external snapshot for disks and external snapshot for memory

2014-10-02 Thread Shanzhi Yu
When create external system checkpoint snapshot, snapshot file for disks
should not be same with snapshot file for memory

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1148932
Signed-off-by: Shanzhi Yu s...@redhat.com
---
 src/conf/snapshot_conf.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c
index 1f83b2c..25af914 100644
--- a/src/conf/snapshot_conf.c
+++ b/src/conf/snapshot_conf.c
@@ -221,6 +221,7 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt,
 char *tmp;
 char *memorySnapshot = NULL;
 char *memoryFile = NULL;
+char *diskFile = NULL;
 bool offline = !!(flags  VIR_DOMAIN_SNAPSHOT_PARSE_OFFLINE);
 
 if (VIR_ALLOC(def)  0)
@@ -299,6 +300,7 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt,
 
 memorySnapshot = virXPathString(string(./memory/@snapshot), ctxt);
 memoryFile = virXPathString(string(./memory/@file), ctxt);
+diskFile = virXPathString(string(./disks/disk/source/@file), ctxt);
 if (memorySnapshot) {
 def-memory = virDomainSnapshotLocationTypeFromString(memorySnapshot);
 if (def-memory = 0) {
@@ -322,6 +324,12 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt,
 }
 } else if (memoryFile) {
 def-memory = VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL;
+if (diskFile != NULL  STREQ(memoryFile,diskFile)){
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s,
+   _(external snapshot file for disks should not be 
same
+  with external snapshot file for memory));
+goto cleanup;
+}
 } else if (flags  VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE) {
 def-memory = (offline ?
VIR_DOMAIN_SNAPSHOT_LOCATION_NONE :
@@ -336,6 +344,7 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt,
 }
 def-file = memoryFile;
 memoryFile = NULL;
+diskFile = NULL;
 
 /* verify that memory path is absolute */
 if (def-file  def-file[0] != '/') {
@@ -379,6 +388,7 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt,
 VIR_FREE(nodes);
 VIR_FREE(memorySnapshot);
 VIR_FREE(memoryFile);
+VIR_FREE(diskFile);
 if (ret == NULL)
 virDomainSnapshotDefFree(def);
 
-- 
1.9.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] qemu: Improve domainSetTime error info report

2014-09-30 Thread Shanzhi Yu
check domain's status before call virQEMUCapsGet to report a accurate
error when domain is shut off

Resolve: https://bugzilla.redhat.com/show_bug.cgi?id=1147847
Signed-off-by: Shanzhi Yu s...@redhat.com
---
 src/qemu/qemu_driver.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index e873d45..da492d7 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -17360,13 +17360,6 @@ qemuDomainSetTime(virDomainPtr dom,
 
 priv = vm-privateData;
 
-if (!virQEMUCapsGet(priv-qemuCaps, QEMU_CAPS_RTC_RESET_REINJECTION)) {
-virReportError(VIR_ERR_OPERATION_UNSUPPORTED, %s,
-   _(cannot set time: qemu doesn't support 
- rtc-reset-reinjection command));
-goto cleanup;
-}
-
 if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY)  0)
 goto cleanup;
 
@@ -17376,6 +17369,13 @@ qemuDomainSetTime(virDomainPtr dom,
 goto endjob;
 }
 
+if (!virQEMUCapsGet(priv-qemuCaps, QEMU_CAPS_RTC_RESET_REINJECTION)) {
+virReportError(VIR_ERR_OPERATION_UNSUPPORTED, %s,
+   _(cannot set time: qemu doesn't support 
+ rtc-reset-reinjection command));
+goto endjob;
+}
+
 if (!qemuDomainAgentAvailable(priv, true))
 goto endjob;
 
-- 
1.9.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] qemu: save domain status after set the blkio parameters

2014-09-29 Thread Shanzhi Yu


- Original Message -
| From: Martin Kletzander mklet...@redhat.com
| To: Shanzhi Yu s...@redhat.com
| Cc: libvir-list@redhat.com
| Sent: Monday, September 29, 2014 3:07:11 PM
| Subject: Re: [libvirt] [PATCH] qemu: save domain status after set the blkio 
parameters
| 
| On Mon, Sep 29, 2014 at 01:14:58PM +0800, Shanzhi Yu wrote:
| After set the blkio parameters for running domain, save the change into
| live xml is needed to survive restarting the libvirtd
| Same story with bug 1146511
| 
| Signed-off-by: Shanzhi Yu s...@redhat.com
| ---
|  src/qemu/qemu_driver.c | 2 ++
|  1 file changed, 2 insertions(+)
| 
| diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
| index 6606154..9c96dea 100644
| --- a/src/qemu/qemu_driver.c
| +++ b/src/qemu/qemu_driver.c
| @@ -8090,6 +8090,8 @@ qemuDomainSetBlkioParameters(virDomainPtr dom,
|  }
|  if (ret  0)
|  goto cleanup;
| +if (virDomainSaveStatus(driver-xmlopt, cfg-stateDir, vm)  0)
| +goto cleanup;
| 
| It this failed, the function would return with 0, so there would be no
| problem indicated and it would also skip the config part.  It should
| be part of the if (flags  VIR_DOMAIN_AFFECT_LIVE).
| 

Yes, thanks for your review, I will send V2. numatune/domiftune also 
have this problem, will fix together 

| I also wonder how come there is no job created for the domain.  That
| needs to be fixed as well.
| 
| Martin
| 

-- 
Regards
shyu

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 1/3] qemu: save domain status after set the blkio parameters

2014-09-29 Thread Shanzhi Yu
After set the blkio parameters for running domain, save the change into
live xml is needed to survive restarting the libvirtd, same story with
bug 1146511, meanwhile add call qemuDomainObjBeginJob/qemuDomainObjEndJob
in qemuDomainSetBlkioParameters

Signed-off-by: Shanzhi Yu s...@redhat.com
---
 src/qemu/qemu_driver.c | 16 +---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 6606154..95244b4 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -7986,15 +7986,18 @@ qemuDomainSetBlkioParameters(virDomainPtr dom,
 if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
 goto cleanup;
 
+if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY)  0)
+goto cleanup;
+
 if (virDomainLiveConfigHelperMethod(caps, driver-xmlopt, vm, flags,
 persistentDef)  0)
-goto cleanup;
+goto endjob;
 
 if (flags  VIR_DOMAIN_AFFECT_LIVE) {
 if (!virCgroupHasController(priv-cgroup, 
VIR_CGROUP_CONTROLLER_BLKIO)) {
 virReportError(VIR_ERR_OPERATION_INVALID, %s,
_(blkio cgroup isn't mounted));
-goto cleanup;
+goto endjob;
 }
 }
 
@@ -8087,9 +8090,12 @@ qemuDomainSetBlkioParameters(virDomainPtr dom,
 VIR_FREE(devices);
 }
 }
+
+if (virDomainSaveStatus(driver-xmlopt, cfg-stateDir, vm)  0)
+goto endjob;
 }
 if (ret  0)
-goto cleanup;
+goto endjob;
 if (flags  VIR_DOMAIN_AFFECT_CONFIG) {
 /* Clang can't see that if we get here, persistentDef was set.  */
 sa_assert(persistentDef);
@@ -8127,6 +8133,10 @@ qemuDomainSetBlkioParameters(virDomainPtr dom,
 ret = -1;
 }
 
+ endjob:
+if (!qemuDomainObjEndJob(driver, vm))
+vm = NULL;
+
  cleanup:
 if (vm)
 virObjectUnlock(vm);
-- 
1.9.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 0/3] Save domain satus after change some parameters

2014-09-29 Thread Shanzhi Yu
Bug:
https://bugzilla.redhat.com/show_bug.cgi?id=1146511

Shanzhi Yu (3):
  qemu: save domain status after set the blkio parameters
  qemu: save domain status after set network interface's bandwidth
parameters
  qemu: save domain status after set domain's numa parameters

 src/qemu/qemu_driver.c | 74 +++---
 1 file changed, 52 insertions(+), 22 deletions(-)

-- 
1.9.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 2/3] qemu: save domain status after set network interface's bandwidth parameters

2014-09-29 Thread Shanzhi Yu
After set network interface's bandwidth for running domain, save the change
into live xml is needed to survive restarting the libvirtd, same story with
bug 1146511, meanwhile add call qemuDomainObjBeginJob/qemuDomainObjEndJob
in qemuDomainSetInterfaceParameters

Signed-off-by: Shanzhi Yu s...@redhat.com
---
 src/qemu/qemu_driver.c | 28 +++-
 1 file changed, 19 insertions(+), 9 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 95244b4..dc3d0e4 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -10133,16 +10133,19 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
 if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
 goto cleanup;
 
+if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY)  0)
+goto cleanup;
+
 if (virDomainLiveConfigHelperMethod(caps, driver-xmlopt, vm, flags,
 persistentDef)  0)
-goto cleanup;
+goto endjob;
 
 if (flags  VIR_DOMAIN_AFFECT_LIVE) {
 net = virDomainNetFind(vm-def, device);
 if (!net) {
 virReportError(VIR_ERR_INVALID_ARG,
_(Can't find device %s), device);
-goto cleanup;
+goto endjob;
 }
 }
 if (flags  VIR_DOMAIN_AFFECT_CONFIG) {
@@ -10150,14 +10153,14 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
 if (!persistentNet) {
 virReportError(VIR_ERR_INVALID_ARG,
_(Can't find device %s), device);
-goto cleanup;
+goto endjob;
 }
 }
 
 if ((VIR_ALLOC(bandwidth)  0) ||
 (VIR_ALLOC(bandwidth-in)  0) ||
 (VIR_ALLOC(bandwidth-out)  0))
-goto cleanup;
+goto endjob;
 
 for (i = 0; i  nparams; i++) {
 virTypedParameterPtr param = params[i];
@@ -10191,7 +10194,7 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
 
 if (flags  VIR_DOMAIN_AFFECT_LIVE) {
 if (VIR_ALLOC(newBandwidth)  0)
-goto cleanup;
+goto endjob;
 
 /* virNetDevBandwidthSet() will clear any previous value of
  * bandwidth parameters, so merge with old bandwidth parameters
@@ -10199,7 +10202,7 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
 if (bandwidth-in ||
 (!inboundSpecified  net-bandwidth  net-bandwidth-in)) {
 if (VIR_ALLOC(newBandwidth-in)  0)
-goto cleanup;
+goto endjob;
 
 memcpy(newBandwidth-in,
bandwidth-in ? bandwidth-in : net-bandwidth-in,
@@ -10208,7 +10211,7 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
 if (bandwidth-out ||
 (!outboundSpecified  net-bandwidth  net-bandwidth-out)) {
 if (VIR_ALLOC(newBandwidth-out)  0)
-goto cleanup;
+goto endjob;
 
 memcpy(newBandwidth-out,
bandwidth-out ? bandwidth-out : net-bandwidth-out,
@@ -10216,7 +10219,7 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
 }
 
 if (virNetDevBandwidthSet(net-ifname, newBandwidth, false)  0)
-goto cleanup;
+goto endjob;
 
 virNetDevBandwidthFree(net-bandwidth);
 if (newBandwidth-in || newBandwidth-out) {
@@ -10225,6 +10228,8 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
 } else {
 net-bandwidth = NULL;
 }
+if (virDomainSaveStatus(driver-xmlopt, cfg-stateDir, vm)  0)
+goto endjob;
 }
 if (flags  VIR_DOMAIN_AFFECT_CONFIG) {
 if (!persistentNet-bandwidth) {
@@ -10248,10 +10253,15 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
 }
 
 if (virDomainSaveConfig(cfg-configDir, persistentDef)  0)
-goto cleanup;
+goto endjob;
 }
 
 ret = 0;
+
+ endjob:
+if (!qemuDomainObjEndJob(driver, vm))
+vm = NULL;
+
  cleanup:
 virNetDevBandwidthFree(bandwidth);
 virNetDevBandwidthFree(newBandwidth);
-- 
1.9.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 3/3] qemu: save domain status after set domain's numa parameters

2014-09-29 Thread Shanzhi Yu
After set domain's numa parameters for running domain, save the change,
save the change into live xml is needed to survive restarting the libvirtd,
same story with bug 1146511; meanwihle add call
qemuDomainObjBeginJob/qemuDomainObjEndJob in qemuDomainSetNumaParameters

Signed-off-by: Shanzhi Yu s...@redhat.com
---
 src/qemu/qemu_driver.c | 30 --
 1 file changed, 20 insertions(+), 10 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index dc3d0e4..4bf3c8c 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -8980,15 +8980,18 @@ qemuDomainSetNumaParameters(virDomainPtr dom,
 if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
 goto cleanup;
 
+if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY)  0)
+goto cleanup;
+
 if (virDomainLiveConfigHelperMethod(caps, driver-xmlopt, vm, flags,
 persistentDef)  0)
-goto cleanup;
+goto endjob;
 
 if (flags  VIR_DOMAIN_AFFECT_LIVE) {
 if (!virCgroupHasController(priv-cgroup, 
VIR_CGROUP_CONTROLLER_CPUSET)) {
 virReportError(VIR_ERR_OPERATION_INVALID, %s,
_(cgroup cpuset controller is not mounted));
-goto cleanup;
+goto endjob;
 }
 }
 
@@ -9001,18 +9004,18 @@ qemuDomainSetNumaParameters(virDomainPtr dom,
 if (mode  0 || mode = VIR_DOMAIN_NUMATUNE_MEM_LAST) {
 virReportError(VIR_ERR_INVALID_ARG,
_(unsupported numatune mode: '%d'), mode);
-goto cleanup;
+goto endjob;
 }
 
 } else if (STREQ(param-field, VIR_DOMAIN_NUMA_NODESET)) {
 if (virBitmapParse(param-value.s, 0, nodeset,
VIR_DOMAIN_CPUMASK_LEN)  0)
-goto cleanup;
+goto endjob;
 
 if (virBitmapIsAllClear(nodeset)) {
 virReportError(VIR_ERR_OPERATION_INVALID, %s,
_(Invalid nodeset for numatune));
-goto cleanup;
+goto endjob;
 }
 }
 }
@@ -9022,18 +9025,21 @@ qemuDomainSetNumaParameters(virDomainPtr dom,
 virDomainNumatuneGetMode(vm-def-numatune, -1) != mode) {
 virReportError(VIR_ERR_OPERATION_INVALID, %s,
_(can't change numatune mode for running domain));
-goto cleanup;
+goto endjob;
 }
 
 if (nodeset 
 qemuDomainSetNumaParamsLive(vm, caps, nodeset)  0)
-goto cleanup;
+goto endjob;
 
 if (virDomainNumatuneSet(vm-def-numatune,
  vm-def-placement_mode ==
  VIR_DOMAIN_CPU_PLACEMENT_MODE_STATIC,
  -1, mode, nodeset)  0)
-goto cleanup;
+goto endjob;
+
+if (virDomainSaveStatus(driver-xmlopt, cfg-stateDir, vm)  0)
+goto endjob;
 }
 
 if (flags  VIR_DOMAIN_AFFECT_CONFIG) {
@@ -9041,14 +9047,18 @@ qemuDomainSetNumaParameters(virDomainPtr dom,
  persistentDef-placement_mode ==
  VIR_DOMAIN_CPU_PLACEMENT_MODE_STATIC,
  -1, mode, nodeset)  0)
-goto cleanup;
+goto endjob;
 
 if (virDomainSaveConfig(cfg-configDir, persistentDef)  0)
-goto cleanup;
+goto endjob;
 }
 
 ret = 0;
 
+ endjob:
+if (!qemuDomainObjEndJob(driver, vm))
+vm = NULL;
+
  cleanup:
 virBitmapFree(nodeset);
 if (vm)
-- 
1.9.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] qemu: save domain status after set the blkio parameters

2014-09-28 Thread Shanzhi Yu
After set the blkio parameters for running domain, save the change into
live xml is needed to survive restarting the libvirtd
Same story with bug 1146511

Signed-off-by: Shanzhi Yu s...@redhat.com
---
 src/qemu/qemu_driver.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 6606154..9c96dea 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -8090,6 +8090,8 @@ qemuDomainSetBlkioParameters(virDomainPtr dom,
 }
 if (ret  0)
 goto cleanup;
+if (virDomainSaveStatus(driver-xmlopt, cfg-stateDir, vm)  0)
+goto cleanup;
 if (flags  VIR_DOMAIN_AFFECT_CONFIG) {
 /* Clang can't see that if we get here, persistentDef was set.  */
 sa_assert(persistentDef);
-- 
1.9.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] configure: improve misleading libnl3-devel missing error message

2014-09-25 Thread Shanzhi Yu
When build libvirt from source with netcf-devel installed, it
will report error libnl-devel =3.0 is required for macvtap
support, actually it requires libnl3-devel

Signed-off-by: Shanzhi Yu s...@redhat.com
---
 configure.ac | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 0062d5d..5b0820a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2613,7 +2613,11 @@ if test $with_linux = yes; then
  [whether the netlink v1 library is available])
 ], [
 if test $with_macvtap = yes; then
-AC_MSG_ERROR([libnl-devel = $LIBNL_REQUIRED is required for 
macvtap support])
+if test $LIBNL_REQUIRED = 3.0;then
+AC_MSG_ERROR([libnl3-devel = $LIBNL_REQUIRED is 
required for macvtap support])
+else
+AC_MSG_ERROR([libnl-devel = $LIBNL_REQUIRED is 
required for macvtap support])
+fi
 fi
 ])
 fi
-- 
1.8.3.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] qemu: add capability probing for block-stream

2014-09-15 Thread Shanzhi Yu
Since block-stream is not supported on qemu-kvm, so libvirt should
post more accurate error info when do blockpull with qemu-kvm but
not Command 'block-stream' is not found

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1140981
Signed-off-by: Shanzhi Yu s...@redhat.com
---
 src/qemu/qemu_capabilities.c |  2 ++
 src/qemu/qemu_capabilities.h |  1 +
 src/qemu/qemu_driver.c   | 13 +
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 81ada48..5674f4f 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -269,6 +269,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
 
   splash-timeout, /* 175 */
   iothread,
+  block-stream,
 );
 
 
@@ -1426,6 +1427,7 @@ struct virQEMUCapsStringFlags virQEMUCapsCommands[] = {
 { query-spice, QEMU_CAPS_SPICE },
 { query-kvm, QEMU_CAPS_KVM },
 { block-commit, QEMU_CAPS_BLOCK_COMMIT },
+{ block-stream, QEMU_CAPS_BLOCK_STREAM },
 { query-vnc, QEMU_CAPS_VNC },
 { drive-mirror, QEMU_CAPS_DRIVE_MIRROR },
 { blockdev-snapshot-sync, QEMU_CAPS_DISK_SNAPSHOT },
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 0980c00..6701965 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -216,6 +216,7 @@ typedef enum {
 QEMU_CAPS_RTC_RESET_REINJECTION = 174, /* rtc-reset-reinjection monitor 
command */
 QEMU_CAPS_SPLASH_TIMEOUT = 175, /* -boot splash-time */
 QEMU_CAPS_OBJECT_IOTHREAD= 176, /* -object iothread */
+QEMU_CAPS_BLOCK_STREAM   = 177, /* block-stream */
 
 QEMU_CAPS_LAST,   /* this must always be the last item */
 } virQEMUCapsFlags;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 73edda3..b38bc91 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -14980,15 +14980,12 @@ qemuDomainBlockJobImpl(virDomainObjPtr vm,
 virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s,
_(block jobs not supported with this QEMU binary));
 goto cleanup;
-} else if (base) {
-virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s,
-   _(partial block pull not supported with this 
- QEMU binary));
-goto cleanup;
-} else if (mode == BLOCK_JOB_PULL  bandwidth) {
+}
+
+if (mode == BLOCK_JOB_PULL 
+!(virQEMUCapsGet(priv-qemuCaps, QEMU_CAPS_BLOCK_STREAM))){
 virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s,
-   _(setting bandwidth at start of block pull not 
- supported with this QEMU binary));
+   _(block pull is not supported with this QEMU binary));
 goto cleanup;
 }
 
-- 
1.8.3.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] Valid pool format type for logical volume pool should be auto and lvm2

2014-06-18 Thread Shanzhi Yu
The logical volume pool supports formats auto and lvm2

Signed-off-by: Shanzhi Yu s...@redhat.com
---
 src/conf/storage_conf.c | 2 +-
 src/conf/storage_conf.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index 8b6fd79..3d61273 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -77,7 +77,7 @@ VIR_ENUM_IMPL(virStoragePoolFormatDisk,
 
 VIR_ENUM_IMPL(virStoragePoolFormatLogical,
   VIR_STORAGE_POOL_LOGICAL_LAST,
-  unknown, lvm2)
+  auto, lvm2)
 
 
 VIR_ENUM_IMPL(virStorageVolFormatDisk,
diff --git a/src/conf/storage_conf.h b/src/conf/storage_conf.h
index 04d99eb..2b08ac5 100644
--- a/src/conf/storage_conf.h
+++ b/src/conf/storage_conf.h
@@ -462,7 +462,7 @@ typedef enum {
 VIR_ENUM_DECL(virStoragePoolFormatDisk)
 
 typedef enum {
-VIR_STORAGE_POOL_LOGICAL_UNKNOWN = 0,
+VIR_STORAGE_POOL_LOGICAL_AUTO = 0,
 VIR_STORAGE_POOL_LOGICAL_LVM2 = 1,
 VIR_STORAGE_POOL_LOGICAL_LAST,
 } virStoragePoolFormatLogical;
-- 
1.9.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] Report an clear error when try to build lvm2 type pool

2014-06-10 Thread Shanzhi Yu
STORAGE_POOL_DISK_LVM2 can't be created by parted mklabel, so
report an error when build such type pool

Signed-off-by: Shanzhi Yu s...@redhat.com
---
 src/storage/storage_backend_disk.c | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/storage/storage_backend_disk.c 
b/src/storage/storage_backend_disk.c
index 8e12974..5b5a1fa 100644
--- a/src/storage/storage_backend_disk.c
+++ b/src/storage/storage_backend_disk.c
@@ -414,13 +414,21 @@ virStorageBackendDiskBuildPool(virConnectPtr conn 
ATTRIBUTE_UNUSED,
 goto error;
 }
 
-if (flags  VIR_STORAGE_POOL_BUILD_OVERWRITE)
+if (flags  VIR_STORAGE_POOL_BUILD_OVERWRITE 
+pool-def-source.format != VIR_STORAGE_POOL_DISK_LVM2)
 ok_to_mklabel = true;
 else {
 int check;
 
 check = virStorageBackendDiskFindLabel(
 pool-def-source.devices[0].path);
+
+if (pool-def-source.format == VIR_STORAGE_POOL_DISK_LVM2){
+virReportError(VIR_ERR_OPERATION_INVALID, %s,
+_(Invalid disk label: lvm2));
+goto error;
+}
+
 if (check  0) {
 ok_to_mklabel = true;
 } else if (check  0) {
-- 
1.9.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] Prevent guest be paused when do external system checkpoint snapshot

2014-05-14 Thread Shanzhi Yu
https://bugzilla.redhat.com/show_bug.cgi?id=1097503

Guest will be paused when do external system checkpoint snapshot with
invalid compression format.

Signed-off-by: Shanzhi Yu s...@redhat.com
---
 src/qemu/qemu_driver.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index a5c7f4f..0761760 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -13207,13 +13207,13 @@ qemuDomainSnapshotCreateActiveExternal(virConnectPtr 
conn,
 virReportError(VIR_ERR_OPERATION_FAILED, %s,
_(Invalid snapshot image format specified 
  in configuration file));
-goto cleanup;
+goto endjob;
 }
 if (!qemuCompressProgramAvailable(compressed)) {
 virReportError(VIR_ERR_OPERATION_FAILED, %s,
_(Compression program for image format 
  in configuration file isn't available));
-goto cleanup;
+goto endjob;
 }
 }
 
-- 
1.8.3.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] Improve the error info when fail to start guest due to lack of cgroup controller

2014-05-13 Thread Shanzhi Yu
When cgroup controller cpu, cpuset and cpuacct are all unmounted,
fail to start guest. The error info is not accurate. It will report
At least one cgroup controller is required even though there is
cgroup controller memory or blkio.

Signed-off-by: Shanzhi Yu s...@redhat.com
---
 src/util/vircgroup.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index fce380a..c609eb3 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -586,6 +586,11 @@ virCgroupDetect(virCgroupPtr group,
 if (!group-controllers[i].mountPoint) {
 VIR_DEBUG(Requested controller '%s' not mounted, 
ignoring,
   virCgroupControllerTypeToString(i));
+if ( i==2 ) {
+virReportSystemError(ENXIO, %s,
+_(At least one cgroup controller 
cpu or cpuacct or cpuset is required)); 
+return -1;
+}
 controllers = ~(1  i);
 }
 } else {
-- 
1.8.3.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] virsh: Add one blank line after output of dompmsuspend/dompmwakeup

2014-04-11 Thread Shanzhi Yu
There should be include one blank line after result of dompmsuspend
and dompmwakeup
---
 tools/virsh-domain.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 73414f8..3aca1e7 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -2830,7 +2830,7 @@ cmdDomPMSuspend(vshControl *ctl, const vshCmd *cmd)
 goto cleanup;
 }
 
-vshPrint(ctl, _(Domain %s successfully suspended),
+vshPrint(ctl, _(Domain %s successfully suspended\n),
  virDomainGetName(dom));
 
 ret = true;
@@ -2881,7 +2881,7 @@ cmdDomPMWakeup(vshControl *ctl, const vshCmd *cmd)
 goto cleanup;
 }
 
-vshPrint(ctl, _(Domain %s successfully woken up),
+vshPrint(ctl, _(Domain %s successfully woken up\n),
  virDomainGetName(dom));
 
 ret = true;
-- 
1.8.3.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH] virsh: man: delete the unexpected character in snapshot-list

2014-04-02 Thread Shanzhi Yu
---
 tools/virsh.pod | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/virsh.pod b/tools/virsh.pod
index ba2da20..98d891a 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -3162,7 +3162,7 @@ with I--current.
 =item Bsnapshot-list Idomain [I--metadata] [I--no-metadata]
 [{I--parent | I--roots | [{I--tree | I--name}]}]
 [{[I--from] Bsnapshot | I--current} [I--descendants]]
-[I--leaves] [I--no-leaves] p[I--inactive] [I--active]
+[I--leaves] [I--no-leaves] [I--inactive] [I--active]
 [I--disk-only] [I--internal] [I--external]
 
 List all of the available snapshots for the given domain, defaulting
-- 
1.9.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list