lingjiao.lc
2011-Oct-27 07:21 UTC
[libvirt-users] delete lvm problem: exited with non-zero status 5 and signal 0
hi, I use the libvirt-python to manage my virtual machine. When I delete a volume use vol.delete(0), sometimes it note me that has occur the error: libvirtError: internal error '/sbin/lvremove -f /dev/vg.vmms/lvm-v097222.sqa.cm4' exited with non-zero status 5 and signal 0: Can't remove open logical volume "lvm-v097222.sqa.cm4". then I go to the host and run the command: " sudo lvchange -a n /dev/vg.vmms/lvm-v097222.sqa.cm4" and then the volume could delete use vol.delete(0). But it's not often occur, just once in nearly 8. I know the delete function virStorageBackendLogicalDeleteVol as this: { { const char *cmdargv[] = { LVREMOVE, "-f",vol->target.path, NULL }; virCheckFlags(0, -1); virFileWaitForDevices(); if (virRun(cmdargv, NULL) < 0) return -1; return 0; } Could I change it like this: ? if (virRun(cmdargv, NULL) < 0) const char *changeCmdarg[] = { LVCHANGE, "-a", "n", vol->target.path, NULL }; if(virRun(changeCmdarg, NULL) < 0) return -1; else if(virRun(cmdargv,NULL) < 0) return -1; ________________________________ This email (including any attachments) is confidential and may be legally privileged. If you received this email in error, please delete it immediately and do not copy it or use it for any purpose or disclose its contents to any other person. Thank you. ???(??????)??????????????????????????????????????????????????????????????????????
Eric Blake
2011-Oct-27 15:35 UTC
[libvirt-users] delete lvm problem: exited with non-zero status 5 and signal 0
On 10/27/2011 01:21 AM, lingjiao.lc wrote:> hi, > I use the libvirt-python to manage my virtual machine. When I delete a > volume use vol.delete(0), sometimes it note me that has occur the error: > > libvirtError: internal error '/sbin/lvremove > -f /dev/vg.vmms/lvm-v097222.sqa.cm4' exited with > non-zero status 5 and signal 0: Can't remove open > logical volume "lvm-v097222.sqa.cm4". >> > Could I change it like this: ? > if (virRun(cmdargv, NULL)< 0) > const char *changeCmdarg[] = { > LVCHANGE, "-a", "n", vol->target.path, NULL > }; > if(virRun(changeCmdarg, NULL)< 0) > return -1; > else > if(virRun(cmdargv,NULL)< 0) > return -1;Changing it like that won't work - virRun fails with -1 if the command exits with non-zero status when the second argument is NULL. But if you pass a pointer to an int on the first call, to capture (and ignore) the exit status of the first command, then you could get to the second call. That said, does calling the change command twice, with no sleep in between, actually improve the situation? The problem is that there is an inherent race in LVM operations, so we have to have a reliable way to tell when the race window is passed. -- Eric Blake eblake at redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org