mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-26 14:03:49 +03:00
libxl_driver: Resolve Coverity errors
1. The virObjectLock() call was unconditional, but Unlock was conditional on vm being valid. Removed the check 2. A call to virDomainEventNewFromObj() isn't guaranteed to return an event - that check needs to be made prior to libxlDomainEventQueue() of the event. Did not add libxlDriverLock/Unlock around the call since some callers already have lock taken 3. Need to initialize fd = -1 in libxlDoDomainSave() since we can jump to cleanup before it's set. 4. Missing break;'s in libxlDomainModifyDeviceFlags() for case LIBXL_DEVICE_UPDATE. The default: case would report an error
This commit is contained in:
parent
50de0e0807
commit
40e904490f
@ -455,8 +455,7 @@ libxlAutostartDomain(virDomainObjPtr vm,
|
||||
|
||||
ret = 0;
|
||||
cleanup:
|
||||
if (vm)
|
||||
virObjectUnlock(vm);
|
||||
virObjectUnlock(vm);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -983,7 +982,8 @@ libxlVmStart(libxlDriverPrivatePtr driver, virDomainObjPtr vm,
|
||||
restore_fd < 0 ?
|
||||
VIR_DOMAIN_EVENT_STARTED_BOOTED :
|
||||
VIR_DOMAIN_EVENT_STARTED_RESTORED);
|
||||
libxlDomainEventQueue(driver, event);
|
||||
if (event)
|
||||
libxlDomainEventQueue(driver, event);
|
||||
|
||||
libxl_domain_config_dispose(&d_config);
|
||||
VIR_FREE(dom_xml);
|
||||
@ -2085,7 +2085,7 @@ libxlDoDomainSave(libxlDriverPrivatePtr driver, virDomainObjPtr vm,
|
||||
virDomainEventPtr event = NULL;
|
||||
char *xml = NULL;
|
||||
uint32_t xml_len;
|
||||
int fd;
|
||||
int fd = -1;
|
||||
int ret = -1;
|
||||
|
||||
if (virDomainObjGetState(vm, NULL) == VIR_DOMAIN_PAUSED) {
|
||||
@ -3561,6 +3561,7 @@ libxlDomainModifyDeviceFlags(virDomainPtr dom, const char *xml,
|
||||
break;
|
||||
case LIBXL_DEVICE_UPDATE:
|
||||
ret = libxlDomainUpdateDeviceConfig(vmdef, dev);
|
||||
break;
|
||||
default:
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("unknown domain modify action %d"), action);
|
||||
@ -3585,6 +3586,7 @@ libxlDomainModifyDeviceFlags(virDomainPtr dom, const char *xml,
|
||||
break;
|
||||
case LIBXL_DEVICE_UPDATE:
|
||||
ret = libxlDomainUpdateDeviceLive(priv, vm, dev);
|
||||
break;
|
||||
default:
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("unknown domain modify action %d"), action);
|
||||
|
Loading…
x
Reference in New Issue
Block a user