Re: [libvirt] [PATCH] fix the failure of nodedev-reattach caused by the variables from nodedev-attach
At 2011-7-2 13:27, Guannan Ren write: On 07/01/2011 11:30 PM, ghostwcy wrote: At 2011-7-1 18:24, Guannan Ren write: the virsh nodedev-reattch command could return successfully, but the pci device is still bound to pci-stub driver. The reason is noddev-reattach trys to use the variables set by nodedev-dettach commands. Becuase these variables is not persistent, this is not we expected. the patch try to fix it. I do not agree with this patch. You should read this mail: https://www.redhat.com/archives/libvir-list/2011-April/msg00315.html This patch will cause regression about hotpluging host pci device. I think the problem is that: the init value of these variables is wrong. We can fix this bug by modifing pciGetDevice() or its caller. I read the patch, it introduced the mechanism to check whether the device is bound to pci-stub when we write dev-id to new_id if a new device with this ID is hotpluggged, or if a probe is triggered for such a device, I think my patch kept it working. I think my explanation is not detailed. For example: The user runs 'virsh attach-device' to pass through host pci device to guest os. We will call the function qemuPrepareHostdevPCIDevices() to bind the pci device to pci-stub, and reset it. If the pci device does not support reset function, we will call pciReAttachDevice() to rollback the things we have done. If the device is alread bound to pci-stub before the user runs 'virsh attach-device', we should do nothing. If the device is not bound to any driver, we should unbound it from pci-stub. If the device is bound to other driver, we should unbound it from pci-stub, and reprobe it. When we call pciReAttachDevice(), the device is bound to pci-stub, but we do the different thing, because the origin state of the pci device is different. So I add these three variables to remember what we do in pciDettachDevice(). The overall idea is as follows: If the device is already bound to pci-stub, then do nothing. If not, try to write dev-id to new_id, then check the state of its driver(hotplug issue) Unbind from its original driver , then bind to pci-stub driver Anyway, we should write dev-id to remove_id to protect the device from causing problems when reattaching it. About fixing the problem from pciGetDevice(), unless we feedback the state of pci device to libvirtd but I don't think it is easier. We already have pciDeviceSetManaged() and pciDeviceGetManaged(). I think we should add some similar APIs in util/pci.c to modify and read these three variables. And we call these new APIs in qemudNodeDeviceDettach() to set these three variables to correct value(I think these three variables should be 1). -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] initialize pointer to NULL
From 577ac7e8594cbcccb59653786e80c3916a3238cb Mon Sep 17 00:00:00 2001 From: Wen Congyang we...@cn.fujitsu.com Date: Sat, 2 Jul 2011 06:41:18 +0800 Subject: [PATCH] initialize pointer to NULL def and cmd is not initialized to NULL, but we try to freed it if we meet some error. It's very dangerous. --- src/qemu/qemu_command.c |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 90a6653..6c78161 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -5818,7 +5818,7 @@ virDomainDefPtr qemuParseCommandLine(virCapsPtr caps, const char **progenv, const char **progargv) { -virDomainDefPtr def; +virDomainDefPtr def = NULL; int i; int nographics = 0; int fullscreen = 0; @@ -5827,7 +5827,7 @@ virDomainDefPtr qemuParseCommandLine(virCapsPtr caps, const char **nics = NULL; int video = VIR_DOMAIN_VIDEO_TYPE_CIRRUS; int nvirtiodisk = 0; -qemuDomainCmdlineDefPtr cmd; +qemuDomainCmdlineDefPtr cmd = NULL; if (!progargv[0]) { qemuReportError(VIR_ERR_INTERNAL_ERROR, -- 1.6.5.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 2/8] qemu: silence coverity warnings
At 2011-7-2 7:36, Eric Blake write: Coverity warns if the majority of callers check a function for errors, but a few don't; but in qemu_audit and qemu_domain, the choice to not check for failures was safe. In qemu_command, the failure to generate a uuid can only occur on a bad pointer. * src/qemu/qemu_audit.c (qemuAuditCgroup): Ignore failure to get cgroup controller. * src/qemu/qemu_domain.c (qemuDomainObjEnterMonitor) (qemuDomainObjEnterMonitorWithDriver): Ignore failure to get timestamp. * src/qemu/qemu_command.c (qemuParseCommandLine): Check for error. --- src/qemu/qemu_audit.c |6 -- src/qemu/qemu_command.c |6 +- src/qemu/qemu_domain.c |4 ++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_audit.c b/src/qemu/qemu_audit.c index 1da0773..1baef40 100644 --- a/src/qemu/qemu_audit.c +++ b/src/qemu/qemu_audit.c @@ -31,6 +31,7 @@ #include uuid.h #include logging.h #include memory.h +#include ignore-value.h /* Return nn:mm in hex for block and character devices, and NULL * for other file types, stat failure, or allocation failure. */ @@ -264,8 +265,9 @@ qemuAuditCgroup(virDomainObjPtr vm, virCgroupPtr cgroup, return; } -virCgroupPathOfController(cgroup, VIR_CGROUP_CONTROLLER_DEVICES, - NULL,controller); +ignore_value(virCgroupPathOfController(cgroup, + VIR_CGROUP_CONTROLLER_DEVICES, + NULL,controller)); detail = virAuditEncode(cgroup, VIR_AUDIT_STR(controller)); VIR_AUDIT(VIR_AUDIT_RECORD_RESOURCE, success, diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 90a6653..fc15f87 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -5842,7 +5842,11 @@ virDomainDefPtr qemuParseCommandLine(virCapsPtr caps, if (VIR_ALLOC(cmd) 0) goto no_memory; -virUUIDGenerate(def-uuid); +if (virUUIDGenerate(def-uuid) 0) { +qemuReportError(VIR_ERR_INTERNAL_ERROR, %s, +_(failed to generate uuid)); +goto error; +} def-id = -1; def-mem.cur_balloon = def-mem.max_balloon = 64 * 1024; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 3af1c86..4b65d87 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -608,7 +608,7 @@ void qemuDomainObjEnterMonitor(virDomainObjPtr obj) qemuMonitorLock(priv-mon); qemuMonitorRef(priv-mon); -virTimeMs(priv-monStart); +ignore_value(virTimeMs(priv-monStart)); virDomainObjUnlock(obj); } @@ -651,7 +651,7 @@ void qemuDomainObjEnterMonitorWithDriver(struct qemud_driver *driver, qemuMonitorLock(priv-mon); qemuMonitorRef(priv-mon); -virTimeMs(priv-monStart); +ignore_value(virTimeMs(priv-monStart)); virDomainObjUnlock(obj); qemuDriverUnlock(driver); } ACK -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 6/8] qemu: avoid null deref on low memory
At 2011-7-2 7:36, Eric Blake write: Detected by Coverity. qemuDomainEventQueue requires a non-NULL pointer; most callers silently drop the event if we encountered and OOM situation trying to create the event. * src/qemu/qemu_migration.c (qemuMigrationFinish): Check for OOM. --- src/qemu/qemu_migration.c |3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 800b714..d7b27a0 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -2552,7 +2552,8 @@ qemuMigrationFinish(struct qemud_driver *driver, VIR_DOMAIN_EVENT_RESUMED_MIGRATED); if (virDomainObjGetState(vm, NULL) == VIR_DOMAIN_PAUSED) { virDomainObjSetState(vm, VIR_DOMAIN_PAUSED, VIR_DOMAIN_PAUSED_USER); -qemuDomainEventQueue(driver, event); +if (event) +qemuDomainEventQueue(driver, event); event = virDomainEventNewFromObj(vm, VIR_DOMAIN_EVENT_SUSPENDED, VIR_DOMAIN_EVENT_SUSPENDED_PAUSED); ACK -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 4/8] cgroup: silence coverity warning
At 2011-7-2 7:36, Eric Blake write: Coverity noted that most clients reacted to failure to hash; but in a best-effort kill loop, we can ignore failure. * src/util/cgroup.c (virCgroupKillInternal): Ignore hash failure. --- src/util/cgroup.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/src/util/cgroup.c b/src/util/cgroup.c index 2e5ef46..740cedf 100644 --- a/src/util/cgroup.c +++ b/src/util/cgroup.c @@ -1395,7 +1395,7 @@ static int virCgroupKillInternal(virCgroupPtr group, int signum, virHashTablePtr done = false; } -virHashAddEntry(pids, (void*)pid, (void*)1); +ignore_value(virHashAddEntry(pids, (void*)pid, (void*)1)); } VIR_FORCE_FCLOSE(fp); } ACK -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 5/8] rpc: fix logic bug
At 2011-7-2 7:36, Eric Blake write: Spotted by Coverity. If we don't update tmp each time through the loop, then if the filter being removed was not the head of the list, we accidentally lose all filters prior to the one we wanted to remove. * src/rpc/virnetserverclient.c (virNetServerClientRemoveFilter): Don't lose unrelated filters. --- src/rpc/virnetserverclient.c |1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/src/rpc/virnetserverclient.c b/src/rpc/virnetserverclient.c index 5c23cf2..30d7fcb 100644 --- a/src/rpc/virnetserverclient.c +++ b/src/rpc/virnetserverclient.c @@ -240,6 +240,7 @@ void virNetServerClientRemoveFilter(virNetServerClientPtr client, VIR_FREE(tmp); break; } +prev = tmp; tmp = tmp-next; } ACK -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 3/8] rpc: silence coverity warning
At 2011-7-2 7:36, Eric Blake write: Coverity noted that 4 out of 5 calls to virNetClientStreamRaiseError checked the return value. This case expects a particular value, so warn if our expectations went wrong due to some bug elsewhere. * src/rpc/virnetclient.c (virNetClientCallDispatchStream): Warn on unexpected scenario. --- src/rpc/virnetclient.c |3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c index b551b99..615de6c 100644 --- a/src/rpc/virnetclient.c +++ b/src/rpc/virnetclient.c @@ -602,7 +602,8 @@ static int virNetClientCallDispatchStream(virNetClientPtr client) if (thecall thecall-expectReply) { VIR_DEBUG(Got a synchronous error); /* Raise error now, so that this call will see it immediately */ -virNetClientStreamRaiseError(st); +if (!virNetClientStreamRaiseError(st)) +VIR_DEBUG(unable to raise synchronous error); thecall-mode = VIR_NET_CLIENT_MODE_COMPLETE; } return 0; ACK -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 7/8] vmware: avoid null deref on failed lookup
At 2011-7-2 7:36, Eric Blake write: Detected by Coverity. * src/vmware/vmware_driver.c (vmwareDomainReboot): Check error before dereferencing memory. --- src/vmware/vmware_driver.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c index 5e2c4ba..52582d6 100644 --- a/src/vmware/vmware_driver.c +++ b/src/vmware/vmware_driver.c @@ -461,7 +461,6 @@ vmwareDomainReboot(virDomainPtr dom, unsigned int flags ATTRIBUTE_UNUSED) vmwareDriverLock(driver); vm = virDomainFindByUUID(driver-domains, dom-uuid); vmwareDriverUnlock(driver); -vmxPath = ((vmwareDomainPtr) vm-privateData)-vmxPath; if (!vm) { vmwareError(VIR_ERR_NO_DOMAIN, %s, @@ -469,6 +468,7 @@ vmwareDomainReboot(virDomainPtr dom, unsigned int flags ATTRIBUTE_UNUSED) goto cleanup; } +vmxPath = ((vmwareDomainPtr) vm-privateData)-vmxPath; vmwareSetSentinal(cmd, vmw_types[driver-type]); vmwareSetSentinal(cmd, vmxPath); ACK -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] initialize pointer to NULL
On 07/02/2011 08:55 AM, Wen Congyang wrote: From 577ac7e8594cbcccb59653786e80c3916a3238cb Mon Sep 17 00:00:00 2001 From: Wen Congyangwe...@cn.fujitsu.com Date: Sat, 2 Jul 2011 06:41:18 +0800 Subject: [PATCH] initialize pointer to NULL def and cmd is not initialized to NULL, but we try to freed it if we meet some error. It's very dangerous. Well, really it's not necessary to initialize def to NULL, because VIR_ALLOC(def) is always called before any point in the code that might goto the error label. So by the time you could get any error, def is already either a valid pointer, or NULL. cmd definitely *does* need to be initialized to NULL, though, because it doesn't get VIR_ALLOCed until after the check for failure of VIR_ALLOC(def) (and resulting goto no_memory). ACK on initializing cmd. Whether or not to initialize def is a matter of style. I prefer not, but others may prefer to do it just in case code is added in the future that causes a jump that bypasses VIR_ALLOC(def). --- src/qemu/qemu_command.c |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 90a6653..6c78161 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -5818,7 +5818,7 @@ virDomainDefPtr qemuParseCommandLine(virCapsPtr caps, const char **progenv, const char **progargv) { -virDomainDefPtr def; +virDomainDefPtr def = NULL; int i; int nographics = 0; int fullscreen = 0; @@ -5827,7 +5827,7 @@ virDomainDefPtr qemuParseCommandLine(virCapsPtr caps, const char **nics = NULL; int video = VIR_DOMAIN_VIDEO_TYPE_CIRRUS; int nvirtiodisk = 0; -qemuDomainCmdlineDefPtr cmd; +qemuDomainCmdlineDefPtr cmd = NULL; if (!progargv[0]) { qemuReportError(VIR_ERR_INTERNAL_ERROR, -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] remote/ssh: support for no_verify.
Set StrictHostKeyChecking=no to auto-accept new ssh host keys if the no_verify extra parameter was specified. This won't disable host key checking for already known hosts. --- src/remote/remote_driver.c |1 + src/rpc/virnetclient.c |3 ++- src/rpc/virnetclient.h |1 + src/rpc/virnetsocket.c |3 +++ src/rpc/virnetsocket.h |1 + tests/virnetsockettest.c |2 ++ 6 files changed, 10 insertions(+), 1 deletions(-) diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index f318740..a2f54c8 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -571,6 +571,7 @@ doRemoteOpen (virConnectPtr conn, command, username, no_tty, +no_verify, netcat ? netcat : nc, sockname))) goto failed; diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c index b551b99..fc0fef8 100644 --- a/src/rpc/virnetclient.c +++ b/src/rpc/virnetclient.c @@ -187,12 +187,13 @@ virNetClientPtr virNetClientNewSSH(const char *nodename, const char *binary, const char *username, bool noTTY, + bool noVerify, const char *netcat, const char *path) { virNetSocketPtr sock; -if (virNetSocketNewConnectSSH(nodename, service, binary, username, noTTY, netcat, path, sock) 0) +if (virNetSocketNewConnectSSH(nodename, service, binary, username, noTTY, noVerify, netcat, path, sock) 0) return NULL; return virNetClientNew(sock, NULL); diff --git a/src/rpc/virnetclient.h b/src/rpc/virnetclient.h index de0782c..6acdf50 100644 --- a/src/rpc/virnetclient.h +++ b/src/rpc/virnetclient.h @@ -44,6 +44,7 @@ virNetClientPtr virNetClientNewSSH(const char *nodename, const char *binary, const char *username, bool noTTY, + bool noVerify, const char *netcat, const char *path); diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c index 4b0c2ee..e827b4f 100644 --- a/src/rpc/virnetsocket.c +++ b/src/rpc/virnetsocket.c @@ -576,6 +576,7 @@ int virNetSocketNewConnectSSH(const char *nodename, const char *binary, const char *username, bool noTTY, + bool noVerify, const char *netcat, const char *path, virNetSocketPtr *retsock) @@ -596,6 +597,8 @@ int virNetSocketNewConnectSSH(const char *nodename, if (noTTY) virCommandAddArgList(cmd, -T, -o, BatchMode=yes, -e, none, NULL); +if (noVerify) +virCommandAddArgList(cmd, -oStrictHostKeyChecking=no, NULL); virCommandAddArgList(cmd, nodename, netcat ? netcat : nc, -U, path, NULL); diff --git a/src/rpc/virnetsocket.h b/src/rpc/virnetsocket.h index 356d6c6..5f882ac 100644 --- a/src/rpc/virnetsocket.h +++ b/src/rpc/virnetsocket.h @@ -67,6 +67,7 @@ int virNetSocketNewConnectSSH(const char *nodename, const char *binary, const char *username, bool noTTY, + bool noVerify, const char *netcat, const char *path, virNetSocketPtr *addr); diff --git a/tests/virnetsockettest.c b/tests/virnetsockettest.c index f6c7274..87f3dfa 100644 --- a/tests/virnetsockettest.c +++ b/tests/virnetsockettest.c @@ -377,6 +377,7 @@ struct testSSHData { const char *binary; const char *username; bool noTTY; +bool noVerify; const char *netcat; const char *path; @@ -397,6 +398,7 @@ static int testSocketSSH(const void *opaque) data-binary, data-username, data-noTTY, + data-noVerify, data-netcat, data-path, csock) 0) -- 1.7.5.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] offline migration / vm cloning with libvirt/virsh
Hi , I am trying to perform offline migration (i.e) Create an incremental image using the qcow format, transfer the vm memory state to a state fie.Use the image and statefile together as a template. Now create a new vm using the template. I can successfully do it using the following commands : Save phase : stop migrate exec:gzip -c STATEFILE.gz qemu-img qemu-img create -b BASE_img -f qcow2 INCRE_img Restore phase : qemu-kvm -m 1024 -hda INCRE_img -incoming exec: gzip -c -d STATEFILE.gz And it works fine. But I am not able to find the vm with virt-manager or other libvirt based tools. If I use : virsh save dom_id STATEFILE I can restore using virsh restore STATEFILE but I want to associate this with the incremental image that I created, but I dont know how. I think it saves the existing vm's xml file along with the STATEFILE, thus I am not able to change the disk image to the incremental image. Thus , 1. Either I should find a way to make vms created using qemu-kvm appear in libvirt-based tools. OR 2. Find a way to associate the virsh save STATEFILE with a incremental image. Any help or hint with respect to these will be very helpful. I am try to do cloning with minimal cost. This takes only 25 seconds ( to create STATEFILE) and creating incremental image is instantatenous . But I want to use the vm monitoring code based on libvirt. And it makes life difficult. Thanks for your help. - Regards, Sethuraman Subbiah Graduate Student - NC state University M.S in Computer Science -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] Network device abstraction aka virtual switch - V3
On 06/16/2011 09:56 PM, Christian Benvenuti (benve) wrote: Laine Stump wrote: Interface Pools --- In many cases, a single host network may have multiple physical network devices associated with it (especially in the case of an SRIOV-capable ethernet card, which will have several virtual functions associated with a single physical ethernet connection). The host will at least want to balance the load of multiple guests between these multiple devices, and may even require (in the case of passthrough mode, for example) that only a single guest interface be attached to each host device. Even though vnlink does not use 'passthrough' (it uses 'private' mode), it actually comes with the same requirement: the lower device cannot be shared. In the case of mode='passthrough', only one guest interface can be connected to a device at a time. In the case of BH that I mentioned above, the libvirt/BH code does not currently enforce it, but it does have the same requirement. Christian, Can this (the fact that the desired mode of operation will not allow for sharing of interfaces) be determined absolutely from the existing config information? In other words, is it safe to say that any time you have the combination of direct/private/802.1Qbh that interfaces can't be shared, but that for direct/private/not-802.1Qbh they *can* be shared? I'm currently writing the code that picks an interface to use from the pool; the information I have is roughly equivalent to what gets configured for current libvirt domain interfaces: | interface type='direct' | source dev='XYZ' mode='private'/ | virtualport type='802.1Qbh | parameters | /virtualport | /interface I want to avoid adding an explicit config item to the XML to allow/prevent interface sharing if at all possible (I already prevent sharing for passthrough mode; if adding a check for private mode with virtualport type='802.1Qbh' would be enough, then I'm happy) -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list