qemudDispatchDomainStart() doesn't report an error if the uuid lookup fails. The patch not only fixes that, but also moves the uuid lookup into the driver so that it matches the way we do Destroy(). Signed-off-by: Mark McLoughlin <markmc@xxxxxxxxxx> Index: libvirt/qemud/driver.c =================================================================== --- libvirt.orig/qemud/driver.c +++ libvirt/qemud/driver.c @@ -285,7 +285,7 @@ struct qemud_vm *qemudDomainCreate(struc return NULL; } - if (qemudDomainStart(server, vm) < 0) { + if (qemudStartVMDaemon(server, vm) < 0) { qemudFreeVM(vm); return NULL; } @@ -339,13 +339,14 @@ int qemudDomainResume(struct qemud_serve int qemudDomainDestroy(struct qemud_server *server, int id) { struct qemud_vm *vm = qemudFindVMByID(server, id); + if (!vm) { - qemudReportError(server, VIR_ERR_INVALID_DOMAIN, "no domain with matching id %d", id); + qemudReportError(server, VIR_ERR_INVALID_DOMAIN, + "no domain with matching id %d", id); return -1; } - if (qemudShutdownVMDaemon(server, vm) < 0) - return -1; - return 0; + + return qemudShutdownVMDaemon(server, vm); } @@ -446,8 +447,16 @@ int qemudNumDefinedDomains(struct qemud_ } -int qemudDomainStart(struct qemud_server *server, struct qemud_vm *vm) { - return qemudStartVMDaemon(server, vm); +struct qemud_vm *qemudDomainStart(struct qemud_server *server, const unsigned char *uuid) { + struct qemud_vm *vm = qemudFindVMByUUID(server, uuid); + + if (!vm) { + qemudReportError(server, VIR_ERR_INVALID_DOMAIN, + "no domain with matching uuid"); + return NULL; + } + + return qemudStartVMDaemon(server, vm) < 0 ? NULL : vm; } @@ -563,7 +572,7 @@ struct qemud_network *qemudNetworkCreate return NULL; } - if (qemudNetworkStart(server, network) < 0) { + if (qemudStartNetworkDaemon(server, network) < 0) { qemudFreeNetwork(network); return NULL; } @@ -609,21 +618,28 @@ int qemudNetworkUndefine(struct qemud_se return 0; } -int qemudNetworkStart(struct qemud_server *server, struct qemud_network *network) { - return qemudStartNetworkDaemon(server, network); +struct qemud_network *qemudNetworkStart(struct qemud_server *server, const unsigned char *uuid) { + struct qemud_network *network = qemudFindNetworkByUUID(server, uuid); + + if (!network) { + qemudReportError(server, VIR_ERR_INVALID_NETWORK, + "no network with matching uuid"); + return NULL; + } + + return qemudStartNetworkDaemon(server, network) < 0 ? NULL : network; } int qemudNetworkDestroy(struct qemud_server *server, const unsigned char *uuid) { struct qemud_network *network = qemudFindNetworkByUUID(server, uuid); + if (!network) { - qemudReportError(server, VIR_ERR_INVALID_NETWORK, "no network with matching uuid"); + qemudReportError(server, VIR_ERR_INVALID_NETWORK, + "no network with matching uuid"); return -1; } - if (qemudShutdownNetworkDaemon(server, network) < 0) - return -1; - - return 0; + return qemudShutdownNetworkDaemon(server, network); } int qemudNetworkDumpXML(struct qemud_server *server, const unsigned char *uuid, char *xml, int xmllen) { Index: libvirt/qemud/driver.h =================================================================== --- libvirt.orig/qemud/driver.h +++ libvirt/qemud/driver.h @@ -79,8 +79,8 @@ int qemudListDefinedDomains(struct qemud char *const*names, int nnames); int qemudNumDefinedDomains(struct qemud_server *server); -int qemudDomainStart(struct qemud_server *server, - struct qemud_vm *vm); +struct qemud_vm *qemudDomainStart(struct qemud_server *server, + const unsigned char *uuid); struct qemud_vm *qemudDomainDefine(struct qemud_server *server, const char *xml); int qemudDomainUndefine(struct qemud_server *server, @@ -103,10 +103,10 @@ struct qemud_network *qemudNetworkCreate const char *xml); struct qemud_network *qemudNetworkDefine(struct qemud_server *server, const char *xml); +struct qemud_network *qemudNetworkStart(struct qemud_server *server, + const unsigned char *uuid); int qemudNetworkUndefine(struct qemud_server *server, const unsigned char *uuid); -int qemudNetworkStart(struct qemud_server *server, - struct qemud_network *network); int qemudNetworkDestroy(struct qemud_server *server, const unsigned char *uuid); int qemudNetworkDumpXML(struct qemud_server *server, Index: libvirt/qemud/dispatch.c =================================================================== --- libvirt.orig/qemud/dispatch.c +++ libvirt/qemud/dispatch.c @@ -257,8 +257,7 @@ static int qemudDispatchDomainDestroy(st if (in->header.dataSize != sizeof(in->data.domainDestroyRequest)) return -1; - int ret = qemudDomainDestroy(server, in->data.domainDestroyRequest.id); - if (ret < 0) { + if (qemudDomainDestroy(server, in->data.domainDestroyRequest.id) < 0) { if (qemudDispatchFailure(server, client, out) < 0) return -1; } else { @@ -410,11 +409,12 @@ static int qemudDispatchNumDefinedDomain static int qemudDispatchDomainStart(struct qemud_server *server, struct qemud_client *client, struct qemud_packet *in, struct qemud_packet *out) { + struct qemud_vm *vm; + if (in->header.dataSize != sizeof(in->data.domainStartRequest)) return -1; - struct qemud_vm *vm = qemudFindVMByUUID(server, in->data.domainStartRequest.uuid); - if (!vm || qemudDomainStart(server, vm) < 0) { + if (!(vm = qemudDomainStart(server, in->data.domainStartRequest.uuid))) { if (qemudDispatchFailure(server, client, out) < 0) return -1; } else { @@ -651,11 +651,12 @@ static int qemudDispatchNetworkUndefine( static int qemudDispatchNetworkStart(struct qemud_server *server, struct qemud_client *client, struct qemud_packet *in, struct qemud_packet *out) { + struct qemud_network *network; + if (in->header.dataSize != sizeof(in->data.networkStartRequest)) return -1; - struct qemud_network *network = qemudFindNetworkByUUID(server, in->data.networkStartRequest.uuid); - if (!network || qemudNetworkStart(server, network) < 0) { + if (!(network = qemudNetworkStart(server, in->data.networkStartRequest.uuid))) { if (qemudDispatchFailure(server, client, out) < 0) return -1; } else { @@ -670,8 +671,7 @@ static int qemudDispatchNetworkDestroy(s if (in->header.dataSize != sizeof(in->data.networkDestroyRequest)) return -1; - int ret = qemudNetworkDestroy(server, in->data.networkDestroyRequest.uuid); - if (ret < 0) { + if (qemudNetworkDestroy(server, in->data.networkDestroyRequest.uuid) < 0) { if (qemudDispatchFailure(server, client, out) < 0) return -1; } else { --