}
/* Find the fully qualified path to the binary for an architecture */
-static char *qemudLocateBinaryForArch(struct qemud_driver *driver ATTRIBUTE_UNUSED,
+static char *qemudLocateBinaryForArch(virConnectPtr conn,
+ struct qemud_driver *driver ATTRIBUTE_UNUSED,
int virtType, const char *arch) {
const char *name;
char *path;
name = qemudDefaultBinaryForArch(arch);
if (!name) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "cannot determin binary for architecture %s", arch);
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "cannot determin binary for architecture %s", arch);
return NULL;
}
/* XXX lame. should actually use $PATH ... */
path = malloc(strlen(name) + strlen("/usr/bin/") + 1);
if (!path) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_NO_MEMORY, "path");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, "path");
return NULL;
}
strcpy(path, "/usr/bin/");
}
}
-int qemudExtractVersion(struct qemud_driver *driver) {
+int qemudExtractVersion(virConnectPtr conn,
+ struct qemud_driver *driver) {
char *binary = NULL;
struct stat sb;
if (driver->qemuVersion > 0)
return 0;
- if (!(binary = qemudLocateBinaryForArch(driver, QEMUD_VIRT_QEMU, "i686")))
+ if (!(binary = qemudLocateBinaryForArch(conn, driver, QEMUD_VIRT_QEMU, "i686")))
return -1;
if (stat(binary, &sb) < 0) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"Cannot find QEMU binary %s: %s", binary,
strerror(errno));
free(binary);
/* Parse the XML definition for a disk */
-static struct qemud_vm_disk_def *qemudParseDiskXML(struct qemud_driver *driver ATTRIBUTE_UNUSED,
+static struct qemud_vm_disk_def *qemudParseDiskXML(virConnectPtr conn,
+ struct qemud_driver *driver ATTRIBUTE_UNUSED,
xmlNodePtr node) {
struct qemud_vm_disk_def *disk = calloc(1, sizeof(struct qemud_vm_disk_def));
xmlNodePtr cur;
int typ = 0;
if (!disk) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_NO_MEMORY, "disk");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, "disk");
return NULL;
}
}
if (source == NULL) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_NO_SOURCE, target ? "%s" : NULL, target);
+ qemudReportError(conn, NULL, NULL, VIR_ERR_NO_SOURCE, target ? "%s" : NULL, target);
goto error;
}
if (target == NULL) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_NO_TARGET, source ? "%s" : NULL, source);
+ qemudReportError(conn, NULL, NULL, VIR_ERR_NO_TARGET, source ? "%s" : NULL, source);
goto error;
}
!strcmp((const char *)device, "floppy") &&
strcmp((const char *)target, "fda") &&
strcmp((const char *)target, "fdb")) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "Invalid floppy device name: %s", target);
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "Invalid floppy device name: %s", target);
goto error;
}
if (device &&
!strcmp((const char *)device, "cdrom") &&
strcmp((const char *)target, "hdc")) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "Invalid cdrom device name: %s", target);
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "Invalid cdrom device name: %s", target);
goto error;
}
strcmp((const char *)target, "hdb") &&
strcmp((const char *)target, "hdc") &&
strcmp((const char *)target, "hdd")) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "Invalid harddisk device name: %s", target);
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "Invalid harddisk device name: %s", target);
goto error;
}
else if (!strcmp((const char *)device, "floppy"))
disk->device = QEMUD_DISK_FLOPPY;
else {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "Invalid device type: %s", device);
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "Invalid device type: %s", device);
goto error;
}
/* Parse the XML definition for a network interface */
-static struct qemud_vm_net_def *qemudParseInterfaceXML(struct qemud_driver *driver ATTRIBUTE_UNUSED,
+static struct qemud_vm_net_def *qemudParseInterfaceXML(virConnectPtr conn,
+ struct qemud_driver *driver ATTRIBUTE_UNUSED,
xmlNodePtr node) {
struct qemud_vm_net_def *net = calloc(1, sizeof(struct qemud_vm_net_def));
xmlNodePtr cur;
xmlChar *port = NULL;
if (!net) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_NO_MEMORY, "net");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, "net");
return NULL;
}
int len;
if (network == NULL) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"No <source> 'network' attribute specified with <interface type='network'/>");
goto error;
} else if ((len = xmlStrlen(network)) >= (QEMUD_MAX_NAME_LEN-1)) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"Network name '%s' too long", network);
goto error;
} else {
if (ifname != NULL) {
if ((len = xmlStrlen(ifname)) >= (BR_IFNAME_MAXLEN-1)) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"TAP interface name '%s' is too long", ifname);
goto error;
} else {
if (script != NULL) {
if ((len = xmlStrlen(script)) >= (PATH_MAX-1)) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"TAP script path '%s' is too long", script);
goto error;
} else {
}
if (ifname != NULL) {
if ((len = xmlStrlen(ifname)) >= (BR_IFNAME_MAXLEN-1)) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"TAP interface name '%s' is too long", ifname);
goto error;
} else {
int len;
if (bridge == NULL) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"No <source> 'dev' attribute specified with <interface type='bridge'/>");
goto error;
} else if ((len = xmlStrlen(bridge)) >= (BR_IFNAME_MAXLEN-1)) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"TAP bridge path '%s' is too long", bridge);
goto error;
} else {
if (ifname != NULL) {
if ((len = xmlStrlen(ifname)) >= (BR_IFNAME_MAXLEN-1)) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"TAP interface name '%s' is too long", ifname);
goto error;
} else {
char *ret;
if (port == NULL) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"No <source> 'port' attribute specified with socket interface");
goto error;
}
if (!(net->dst.socket.port = strtol((char*)port, &ret, 10)) &&
ret == (char*)port) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"Cannot parse <source> 'port' attribute with socket interface");
goto error;
}
if (address == NULL) {
if (net->type == QEMUD_NET_CLIENT ||
net->type == QEMUD_NET_MCAST) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"No <source> 'address' attribute specified with socket interface");
goto error;
}
} else if ((len = xmlStrlen(address)) >= (BR_INET_ADDR_MAXLEN)) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"IP address '%s' is too long", address);
goto error;
}
* Parses a libvirt XML definition of a guest, and populates the
* the qemud_vm struct with matching data about the guests config
*/
-static struct qemud_vm_def *qemudParseXML(struct qemud_driver *driver,
+static struct qemud_vm_def *qemudParseXML(virConnectPtr conn,
+ struct qemud_driver *driver,
xmlDocPtr xml) {
xmlNodePtr root = NULL;
xmlChar *prop = NULL;
struct qemud_vm_def *def;
if (!(def = calloc(1, sizeof(struct qemud_vm_def)))) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_NO_MEMORY, "xmlXPathContext");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, "xmlXPathContext");
return NULL;
}
/* Prepare parser / xpath context */
root = xmlDocGetRootElement(xml);
if ((root == NULL) || (!xmlStrEqual(root->name, BAD_CAST "domain"))) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "incorrect root element");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "incorrect root element");
goto error;
}
ctxt = xmlXPathNewContext(xml);
if (ctxt == NULL) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_NO_MEMORY, "xmlXPathContext");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, "xmlXPathContext");
goto error;
}
/* Find out what type of QEMU virtualization to use */
if (!(prop = xmlGetProp(root, BAD_CAST "type"))) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "missing domain type attribute");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "missing domain type attribute");
goto error;
}
else if (!strcmp((char *)prop, "kvm"))
def->virtType = QEMUD_VIRT_KVM;
else {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "invalid domain type attribute");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "invalid domain type attribute");
goto error;
}
free(prop);
obj = xmlXPathEval(BAD_CAST "string(/domain/name[1])", ctxt);
if ((obj == NULL) || (obj->type != XPATH_STRING) ||
(obj->stringval == NULL) || (obj->stringval[0] == 0)) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_NO_NAME, NULL);
+ qemudReportError(conn, NULL, NULL, VIR_ERR_NO_NAME, NULL);
goto error;
}
if (strlen((const char *)obj->stringval) >= (QEMUD_MAX_NAME_LEN-1)) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "domain name length too long");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "domain name length too long");
goto error;
}
strcpy(def->name, (const char *)obj->stringval);
(obj->stringval == NULL) || (obj->stringval[0] == 0)) {
int err;
if ((err = virUUIDGenerate(def->uuid))) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"Failed to generate UUID: %s", strerror(err));
goto error;
}
} else if (virUUIDParse((const char *)obj->stringval, def->uuid) < 0) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "malformed uuid element");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "malformed uuid element");
goto error;
}
xmlXPathFreeObject(obj);
obj = xmlXPathEval(BAD_CAST "string(/domain/memory[1])", ctxt);
if ((obj == NULL) || (obj->type != XPATH_STRING) ||
(obj->stringval == NULL) || (obj->stringval[0] == 0)) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "missing memory element");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "missing memory element");
goto error;
} else {
conv = NULL;
def->maxmem = strtoll((const char*)obj->stringval, &conv, 10);
if (conv == (const char*)obj->stringval) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "malformed memory information");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "malformed memory information");
goto error;
}
}
if (def->memory > def->maxmem)
def->memory = def->maxmem;
if (conv == (const char*)obj->stringval) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "malformed memory information");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "malformed memory information");
goto error;
}
}
conv = NULL;
def->vcpus = strtoll((const char*)obj->stringval, &conv, 10);
if (conv == (const char*)obj->stringval) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "malformed vcpu information");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "malformed vcpu information");
goto error;
}
}
obj = xmlXPathEval(BAD_CAST "string(/domain/os/type[1])", ctxt);
if ((obj == NULL) || (obj->type != XPATH_STRING) ||
(obj->stringval == NULL) || (obj->stringval[0] == 0)) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_OS_TYPE, NULL);
+ qemudReportError(conn, NULL, NULL, VIR_ERR_OS_TYPE, NULL);
goto error;
}
if (strcmp((const char *)obj->stringval, "hvm")) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_OS_TYPE, "%s", obj->stringval);
+ qemudReportError(conn, NULL, NULL, VIR_ERR_OS_TYPE, "%s", obj->stringval);
goto error;
}
strcpy(def->os.type, (const char *)obj->stringval);
(obj->stringval == NULL) || (obj->stringval[0] == 0)) {
const char *defaultArch = qemudDefaultArch();
if (strlen(defaultArch) >= (QEMUD_OS_TYPE_MAX_LEN-1)) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "architecture type too long");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "architecture type too long");
goto error;
}
strcpy(def->os.arch, defaultArch);
} else {
if (strlen((const char *)obj->stringval) >= (QEMUD_OS_TYPE_MAX_LEN-1)) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "architecture type too long");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "architecture type too long");
goto error;
}
strcpy(def->os.arch, (const char *)obj->stringval);
(obj->stringval == NULL) || (obj->stringval[0] == 0)) {
const char *defaultMachine = qemudDefaultMachineForArch(def->os.arch);
if (strlen(defaultMachine) >= (QEMUD_OS_MACHINE_MAX_LEN-1)) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "machine type too long");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "machine type too long");
goto error;
}
strcpy(def->os.machine, defaultMachine);
} else {
if (strlen((const char *)obj->stringval) >= (QEMUD_OS_MACHINE_MAX_LEN-1)) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "architecture type too long");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "architecture type too long");
goto error;
}
strcpy(def->os.machine, (const char *)obj->stringval);
if ((obj != NULL) && (obj->type == XPATH_STRING) &&
(obj->stringval != NULL) && (obj->stringval[0] != 0)) {
if (strlen((const char *)obj->stringval) >= (PATH_MAX-1)) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "kernel path too long");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "kernel path too long");
goto error;
}
strcpy(def->os.kernel, (const char *)obj->stringval);
if ((obj != NULL) && (obj->type == XPATH_STRING) &&
(obj->stringval != NULL) && (obj->stringval[0] != 0)) {
if (strlen((const char *)obj->stringval) >= (PATH_MAX-1)) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "initrd path too long");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "initrd path too long");
goto error;
}
strcpy(def->os.initrd, (const char *)obj->stringval);
if ((obj != NULL) && (obj->type == XPATH_STRING) &&
(obj->stringval != NULL) && (obj->stringval[0] != 0)) {
if (strlen((const char *)obj->stringval) >= (PATH_MAX-1)) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "cmdline arguments too long");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "cmdline arguments too long");
goto error;
}
strcpy(def->os.cmdline, (const char *)obj->stringval);
obj = xmlXPathEval(BAD_CAST "string(/domain/devices/emulator[1])", ctxt);
if ((obj == NULL) || (obj->type != XPATH_STRING) ||
(obj->stringval == NULL) || (obj->stringval[0] == 0)) {
- char *tmp = qemudLocateBinaryForArch(driver, def->virtType, def->os.arch);
+ char *tmp = qemudLocateBinaryForArch(conn, driver, def->virtType, def->os.arch);
if (!tmp) {
goto error;
}
free(tmp);
} else {
if (strlen((const char *)obj->stringval) >= (PATH_MAX-1)) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "emulator path too long");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "emulator path too long");
goto error;
}
strcpy(def->os.binary, (const char *)obj->stringval);
} else if (!strcmp((char *)prop, "sdl")) {
def->graphicsType = QEMUD_GRAPHICS_SDL;
} else {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "Unsupported graphics type %s", prop);
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "Unsupported graphics type %s", prop);
goto error;
}
xmlFree(prop);
struct qemud_vm_disk_def *prev = NULL;
for (i = 0; i < obj->nodesetval->nodeNr; i++) {
struct qemud_vm_disk_def *disk;
- if (!(disk = qemudParseDiskXML(driver, obj->nodesetval->nodeTab[i]))) {
+ if (!(disk = qemudParseDiskXML(conn, driver, obj->nodesetval->nodeTab[i]))) {
goto error;
}
def->ndisks++;
struct qemud_vm_net_def *prev = NULL;
for (i = 0; i < obj->nodesetval->nodeNr; i++) {
struct qemud_vm_net_def *net;
- if (!(net = qemudParseInterfaceXML(driver, obj->nodesetval->nodeTab[i]))) {
+ if (!(net = qemudParseInterfaceXML(conn, driver, obj->nodesetval->nodeTab[i]))) {
goto error;
}
def->nnets++;
static char *
-qemudNetworkIfaceConnect(struct qemud_driver *driver,
+qemudNetworkIfaceConnect(virConnectPtr conn,
+ struct qemud_driver *driver,
struct qemud_vm *vm,
struct qemud_vm_net_def *net,
int vlan)
if (net->type == QEMUD_NET_NETWORK) {
if (!(network = qemudFindNetworkByName(driver, net->dst.network.name))) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"Network '%s' not found", net->dst.network.name);
goto error;
} else if (network->bridge[0] == '\0') {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"Network '%s' not active", net->dst.network.name);
goto error;
}
}
ifname = net->dst.bridge.ifname;
} else {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"Network type %d is not supported", net->type);
goto error;
}
if (!driver->brctl && (err = brInit(&driver->brctl))) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"cannot initialize bridge support: %s", strerror(err));
goto error;
}
if ((err = brAddTap(driver->brctl, brname,
ifname, BR_IFNAME_MAXLEN, &tapfd))) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"Failed to add tap interface '%s' to bridge '%s' : %s",
ifname, brname, strerror(err));
goto error;
return retval;
no_memory:
- qemudReportError(NULL, NULL, NULL, VIR_ERR_NO_MEMORY, "tapfds");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, "tapfds");
error:
if (retval)
free(retval);
* Constructs a argv suitable for launching qemu with config defined
* for a given virtual machine.
*/
-int qemudBuildCommandLine(struct qemud_driver *driver,
+int qemudBuildCommandLine(virConnectPtr conn,
+ struct qemud_driver *driver,
struct qemud_vm *vm,
char ***argv) {
int len, n = -1, i;
struct utsname ut;
int disableKQEMU = 0;
- if (qemudExtractVersion(driver) < 0)
+ if (qemudExtractVersion(conn, driver) < 0)
return -1;
uname(&ut);
* in a sub-process so its hard to feed back a useful error
*/
if (stat(vm->def->os.binary, &sb) < 0) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"Cannot find QEMU binary %s: %s", vm->def->os.binary,
strerror(errno));
return -1;
switch (net->type) {
case QEMUD_NET_NETWORK:
case QEMUD_NET_BRIDGE:
- if (!((*argv)[++n] = qemudNetworkIfaceConnect(driver, vm, net, vlan)))
+ if (!((*argv)[++n] = qemudNetworkIfaceConnect(conn, driver, vm, net, vlan)))
goto error;
break;
return 0;
no_memory:
- qemudReportError(NULL, NULL, NULL, VIR_ERR_NO_MEMORY, "argv");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, "argv");
error:
if (vm->tapfds) {
for (i = 0; vm->tapfds[i] != -1; i++)
/* Save a guest's config data into a persistent file */
-static int qemudSaveConfig(struct qemud_driver *driver,
+static int qemudSaveConfig(virConnectPtr conn,
+ struct qemud_driver *driver,
struct qemud_vm *vm,
struct qemud_vm_def *def) {
char *xml;
int fd = -1, ret = -1;
int towrite;
- if (!(xml = qemudGenerateXML(driver, vm, def, 0)))
+ if (!(xml = qemudGenerateXML(conn, driver, vm, def, 0)))
return -1;
if ((fd = open(vm->configFile,
O_WRONLY | O_CREAT | O_TRUNC,
S_IRUSR | S_IWUSR )) < 0) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"cannot create config file %s: %s",
vm->configFile, strerror(errno));
goto cleanup;
towrite = strlen(xml);
if (write(fd, xml, towrite) != towrite) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"cannot write config file %s: %s",
vm->configFile, strerror(errno));
goto cleanup;
}
if (close(fd) < 0) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"cannot save config file %s: %s",
vm->configFile, strerror(errno));
goto cleanup;
}
struct qemud_vm_def *
-qemudParseVMDef(struct qemud_driver *driver,
+qemudParseVMDef(virConnectPtr conn,
+ struct qemud_driver *driver,
const char *xmlStr,
const char *displayName) {
xmlDocPtr xml;
if (!(xml = xmlReadDoc(BAD_CAST xmlStr, displayName ? displayName : "domain.xml", NULL,
XML_PARSE_NOENT | XML_PARSE_NONET |
XML_PARSE_NOERROR | XML_PARSE_NOWARNING))) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_XML_ERROR, NULL);
+ qemudReportError(conn, NULL, NULL, VIR_ERR_XML_ERROR, NULL);
return NULL;
}
- def = qemudParseXML(driver, xml);
+ def = qemudParseXML(conn, driver, xml);
xmlFreeDoc(xml);
}
struct qemud_vm *
-qemudAssignVMDef(struct qemud_driver *driver,
+qemudAssignVMDef(virConnectPtr conn,
+ struct qemud_driver *driver,
struct qemud_vm_def *def)
{
struct qemud_vm *vm = NULL;
}
if (!(vm = calloc(1, sizeof(struct qemud_vm)))) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_NO_MEMORY, "vm");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, "vm");
return NULL;
}
}
int
-qemudSaveVMDef(struct qemud_driver *driver,
+qemudSaveVMDef(virConnectPtr conn,
+ struct qemud_driver *driver,
struct qemud_vm *vm,
struct qemud_vm_def *def) {
if (vm->configFile[0] == '\0') {
int err;
if ((err = qemudEnsureDir(driver->configDir))) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"cannot create config directory %s: %s",
driver->configDir, strerror(err));
return -1;
if (qemudMakeConfigPath(driver->configDir, def->name, ".xml",
vm->configFile, PATH_MAX) < 0) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"cannot construct config file path");
return -1;
}
if (qemudMakeConfigPath(driver->autostartDir, def->name, ".xml",
vm->autostartLink, PATH_MAX) < 0) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"cannot construct autostart link path");
vm->configFile[0] = '\0';
return -1;
}
}
- return qemudSaveConfig(driver, vm, def);
+ return qemudSaveConfig(conn, driver, vm, def);
}
-static int qemudSaveNetworkConfig(struct qemud_driver *driver,
+static int qemudSaveNetworkConfig(virConnectPtr conn,
+ struct qemud_driver *driver,
struct qemud_network *network,
struct qemud_network_def *def) {
char *xml;
int towrite;
int err;
- if (!(xml = qemudGenerateNetworkXML(driver, network, def))) {
+ if (!(xml = qemudGenerateNetworkXML(conn, driver, network, def))) {
return -1;
}
if ((err = qemudEnsureDir(driver->networkConfigDir))) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"cannot create config directory %s: %s",
driver->networkConfigDir, strerror(err));
goto cleanup;
if ((fd = open(network->configFile,
O_WRONLY | O_CREAT | O_TRUNC,
S_IRUSR | S_IWUSR )) < 0) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"cannot create config file %s: %s",
network->configFile, strerror(errno));
goto cleanup;
towrite = strlen(xml);
if (write(fd, xml, towrite) != towrite) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"cannot write config file %s: %s",
network->configFile, strerror(errno));
goto cleanup;
}
if (close(fd) < 0) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"cannot save config file %s: %s",
network->configFile, strerror(errno));
goto cleanup;
return 1;
}
-static int qemudParseDhcpRangesXML(struct qemud_driver *driver ATTRIBUTE_UNUSED,
+static int qemudParseDhcpRangesXML(virConnectPtr conn,
+ struct qemud_driver *driver ATTRIBUTE_UNUSED,
struct qemud_network_def *def,
xmlNodePtr node) {
}
if (!(range = calloc(1, sizeof(struct qemud_dhcp_range_def)))) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_NO_MEMORY, "range");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, "range");
return 0;
}
return 1;
}
-static int qemudParseInetXML(struct qemud_driver *driver ATTRIBUTE_UNUSED,
+static int qemudParseInetXML(virConnectPtr conn,
+ struct qemud_driver *driver ATTRIBUTE_UNUSED,
struct qemud_network_def *def,
xmlNodePtr node) {
xmlChar *address, *netmask;
while (cur != NULL) {
if (cur->type == XML_ELEMENT_NODE &&
xmlStrEqual(cur->name, BAD_CAST "dhcp") &&
- !qemudParseDhcpRangesXML(driver, def, cur))
+ !qemudParseDhcpRangesXML(conn, driver, def, cur))
return 0;
cur = cur->next;
}
}
-static struct qemud_network_def *qemudParseNetworkXML(struct qemud_driver *driver,
+static struct qemud_network_def *qemudParseNetworkXML(virConnectPtr conn,
+ struct qemud_driver *driver,
xmlDocPtr xml) {
xmlNodePtr root = NULL;
xmlXPathContextPtr ctxt = NULL;
struct qemud_network_def *def;
if (!(def = calloc(1, sizeof(struct qemud_network_def)))) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_NO_MEMORY, "network_def");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, "network_def");
return NULL;
}
/* Prepare parser / xpath context */
root = xmlDocGetRootElement(xml);
if ((root == NULL) || (!xmlStrEqual(root->name, BAD_CAST "network"))) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "incorrect root element");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "incorrect root element");
goto error;
}
ctxt = xmlXPathNewContext(xml);
if (ctxt == NULL) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_NO_MEMORY, "xmlXPathContext");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, "xmlXPathContext");
goto error;
}
obj = xmlXPathEval(BAD_CAST "string(/network/name[1])", ctxt);
if ((obj == NULL) || (obj->type != XPATH_STRING) ||
(obj->stringval == NULL) || (obj->stringval[0] == 0)) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_NO_NAME, NULL);
+ qemudReportError(conn, NULL, NULL, VIR_ERR_NO_NAME, NULL);
goto error;
}
if (strlen((const char *)obj->stringval) >= (QEMUD_MAX_NAME_LEN-1)) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "network name length too long");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "network name length too long");
goto error;
}
strcpy(def->name, (const char *)obj->stringval);
(obj->stringval == NULL) || (obj->stringval[0] == 0)) {
int err;
if ((err = virUUIDGenerate(def->uuid))) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"Failed to generate UUID: %s", strerror(err));
goto error;
}
} else if (virUUIDParse((const char *)obj->stringval, def->uuid) < 0) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "malformed uuid element");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s", "malformed uuid element");
goto error;
}
xmlXPathFreeObject(obj);
obj = xmlXPathEval(BAD_CAST "/network/ip[1]", ctxt);
if ((obj != NULL) && (obj->type == XPATH_NODESET) &&
(obj->nodesetval != NULL) && (obj->nodesetval->nodeNr > 0)) {
- if (!qemudParseInetXML(driver, def, obj->nodesetval->nodeTab[0])) {
+ if (!qemudParseInetXML(conn, driver, def, obj->nodesetval->nodeTab[0])) {
goto error;
}
}
obj->boolval) {
if (!def->ipAddress[0] ||
!def->netmask[0]) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"Forwarding requested, but no IPv4 address/netmask provided");
goto error;
}
(tmp->stringval != NULL) && (tmp->stringval[0] != 0)) {
int len;
if ((len = xmlStrlen(tmp->stringval)) >= (BR_IFNAME_MAXLEN-1)) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"forward device name '%s' is too long",
(char*)tmp->stringval);
goto error;
}
struct qemud_network_def *
-qemudParseNetworkDef(struct qemud_driver *driver,
+qemudParseNetworkDef(virConnectPtr conn,
+ struct qemud_driver *driver,
const char *xmlStr,
const char *displayName) {
xmlDocPtr xml;
if (!(xml = xmlReadDoc(BAD_CAST xmlStr, displayName ? displayName : "network.xml", NULL,
XML_PARSE_NOENT | XML_PARSE_NONET |
XML_PARSE_NOERROR | XML_PARSE_NOWARNING))) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_XML_ERROR, NULL);
+ qemudReportError(conn, NULL, NULL, VIR_ERR_XML_ERROR, NULL);
return NULL;
}
- def = qemudParseNetworkXML(driver, xml);
+ def = qemudParseNetworkXML(conn, driver, xml);
xmlFreeDoc(xml);
}
struct qemud_network *
-qemudAssignNetworkDef(struct qemud_driver *driver,
+qemudAssignNetworkDef(virConnectPtr conn,
+ struct qemud_driver *driver,
struct qemud_network_def *def) {
struct qemud_network *network;
}
if (!(network = calloc(1, sizeof(struct qemud_network)))) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_NO_MEMORY, "network");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, "network");
return NULL;
}
}
int
-qemudSaveNetworkDef(struct qemud_driver *driver,
+qemudSaveNetworkDef(virConnectPtr conn,
+ struct qemud_driver *driver,
struct qemud_network *network,
struct qemud_network_def *def) {
int err;
if ((err = qemudEnsureDir(driver->networkConfigDir))) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"cannot create config directory %s: %s",
driver->networkConfigDir, strerror(err));
return -1;
if (qemudMakeConfigPath(driver->networkConfigDir, def->name, ".xml",
network->configFile, PATH_MAX) < 0) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"cannot construct config file path");
return -1;
}
if (qemudMakeConfigPath(driver->networkAutostartDir, def->name, ".xml",
network->autostartLink, PATH_MAX) < 0) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"cannot construct autostart link path");
network->configFile[0] = '\0';
return -1;
}
}
- return qemudSaveNetworkConfig(driver, network, def);
+ return qemudSaveNetworkConfig(conn, driver, network, def);
}
static int
struct qemud_vm_def *def;
struct qemud_vm *vm;
- if (!(def = qemudParseVMDef(driver, xml, file))) {
+ if (!(def = qemudParseVMDef(NULL, driver, xml, file))) {
virErrorPtr err = virGetLastError();
qemudLog(QEMUD_WARN, "Error parsing QEMU guest config '%s' : %s",
path, err->message);
return NULL;
}
- if (!(vm = qemudAssignVMDef(driver, def))) {
+ if (!(vm = qemudAssignVMDef(NULL, driver, def))) {
qemudLog(QEMUD_WARN, "Failed to load QEMU guest config '%s': out of memory", path);
qemudFreeVMDef(def);
return NULL;
struct qemud_network_def *def;
struct qemud_network *network;
- if (!(def = qemudParseNetworkDef(driver, xml, file))) {
+ if (!(def = qemudParseNetworkDef(NULL, driver, xml, file))) {
virErrorPtr err = virGetLastError();
qemudLog(QEMUD_WARN, "Error parsing network config '%s' : %s",
path, err->message);
return NULL;
}
- if (!(network = qemudAssignNetworkDef(driver, def))) {
+ if (!(network = qemudAssignNetworkDef(NULL, driver, def))) {
qemudLog(QEMUD_WARN, "Failed to load network config '%s': out of memory", path);
qemudFreeNetworkDef(def);
return NULL;
}
/* Generate an XML document describing the guest's configuration */
-char *qemudGenerateXML(struct qemud_driver *driver ATTRIBUTE_UNUSED,
+char *qemudGenerateXML(virConnectPtr conn,
+ struct qemud_driver *driver ATTRIBUTE_UNUSED,
struct qemud_vm *vm,
struct qemud_vm_def *def,
int live) {
break;
}
if (!type) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "unexpected domain type %d", def->virtType);
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "unexpected domain type %d", def->virtType);
goto cleanup;
}
return virBufferContentAndFree (buf);
no_memory:
- qemudReportError(NULL, NULL, NULL, VIR_ERR_NO_MEMORY, "xml");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, "xml");
cleanup:
if (buf) virBufferFree (buf);
return NULL;
}
-char *qemudGenerateNetworkXML(struct qemud_driver *driver ATTRIBUTE_UNUSED,
+char *qemudGenerateNetworkXML(virConnectPtr conn,
+ struct qemud_driver *driver ATTRIBUTE_UNUSED,
struct qemud_network *network,
struct qemud_network_def *def) {
virBufferPtr buf = 0;
return virBufferContentAndFree (buf);
no_memory:
- qemudReportError(NULL, NULL, NULL, VIR_ERR_NO_MEMORY, "xml");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, "xml");
if (buf) virBufferFree (buf);
return NULL;
}
-int qemudDeleteConfig(struct qemud_driver *driver ATTRIBUTE_UNUSED,
+int qemudDeleteConfig(virConnectPtr conn,
+ struct qemud_driver *driver ATTRIBUTE_UNUSED,
const char *configFile,
const char *name) {
if (!configFile[0]) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "no config file for %s", name);
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "no config file for %s", name);
return -1;
}
if (unlink(configFile) < 0) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "cannot remove config for %s", name);
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "cannot remove config for %s", name);
return -1;
}
static void qemudDispatchVMEvent(int fd, int events, void *opaque);
-static int qemudStartVMDaemon(struct qemud_driver *driver,
- struct qemud_vm *vm);
+static int qemudStartVMDaemon(virConnectPtr conn,
+ struct qemud_driver *driver,
+ struct qemud_vm *vm);
-static int qemudShutdownVMDaemon(struct qemud_driver *driver,
- struct qemud_vm *vm);
+static int qemudShutdownVMDaemon(virConnectPtr conn,
+ struct qemud_driver *driver,
+ struct qemud_vm *vm);
-static int qemudStartNetworkDaemon(struct qemud_driver *driver,
- struct qemud_network *network);
+static int qemudStartNetworkDaemon(virConnectPtr conn,
+ struct qemud_driver *driver,
+ struct qemud_network *network);
-static int qemudShutdownNetworkDaemon(struct qemud_driver *driver,
- struct qemud_network *network);
+static int qemudShutdownNetworkDaemon(virConnectPtr conn,
+ struct qemud_driver *driver,
+ struct qemud_network *network);
struct qemud_driver *qemu_driver = NULL;
if (network->autostart &&
!qemudIsActiveNetwork(network) &&
- qemudStartNetworkDaemon(driver, network) < 0) {
+ qemudStartNetworkDaemon(NULL, driver, network) < 0) {
virErrorPtr err = virGetLastError();
qemudLog(QEMUD_ERR, "Failed to autostart network '%s': %s",
network->def->name, err->message);
if (vm->autostart &&
!qemudIsActiveVM(vm) &&
- qemudStartVMDaemon(driver, vm) < 0) {
+ qemudStartVMDaemon(NULL, driver, vm) < 0) {
virErrorPtr err = virGetLastError();
qemudLog(QEMUD_ERR, "Failed to autostart VM '%s': %s",
vm->def->name, err->message);
while (vm) {
struct qemud_vm *next = vm->next;
if (qemudIsActiveVM(vm))
- qemudShutdownVMDaemon(qemu_driver, vm);
+ qemudShutdownVMDaemon(NULL, qemu_driver, vm);
vm = next;
}
while (network) {
struct qemud_network *next = network->next;
if (qemudIsActiveNetwork(network))
- qemudShutdownNetworkDaemon(qemu_driver, network);
+ qemudShutdownNetworkDaemon(NULL, qemu_driver, network);
network = next;
}
}
static int
-qemudExec(char **argv,
+qemudExec(virConnectPtr conn,
+ char **argv,
int *retpid, int *outfd, int *errfd) {
int pid, null;
int pipeout[2] = {-1,-1};
int pipeerr[2] = {-1,-1};
if ((null = open(_PATH_DEVNULL, O_RDONLY)) < 0) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "cannot open %s : %s",
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "cannot open %s : %s",
_PATH_DEVNULL, strerror(errno));
goto cleanup;
}
if ((outfd != NULL && pipe(pipeout) < 0) ||
(errfd != NULL && pipe(pipeerr) < 0)) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "cannot create pipe : %s",
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "cannot create pipe : %s",
strerror(errno));
goto cleanup;
}
if ((pid = fork()) < 0) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "cannot fork child process : %s",
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "cannot fork child process : %s",
strerror(errno));
goto cleanup;
}
}
/* Return -1 for error, 1 to continue reading and 0 for success */
-typedef int qemudHandlerMonitorOutput(struct qemud_driver *driver,
+typedef int qemudHandlerMonitorOutput(virConnectPtr conn,
+ struct qemud_driver *driver,
struct qemud_vm *vm,
const char *output,
int fd);
static int
-qemudReadMonitorOutput(struct qemud_driver *driver,
+qemudReadMonitorOutput(virConnectPtr conn,
+ struct qemud_driver *driver,
struct qemud_vm *vm,
int fd,
char *buf,
ret = read(fd, buf+got, buflen-got-1);
if (ret == 0) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"QEMU quit during %s startup\n%s", what, buf);
return -1;
}
continue;
if (errno != EAGAIN) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"Failure while reading %s startup output: %s",
what, strerror(errno));
return -1;
ret = poll(&pfd, 1, MONITOR_TIMEOUT);
if (ret == 0) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"Timed out while reading %s startup output", what);
return -1;
} else if (ret == -1) {
if (errno != EINTR) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"Failure while reading %s startup output: %s",
what, strerror(errno));
return -1;
if (pfd.revents & (POLLIN | POLLHUP))
continue;
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"Failure while reading %s startup output", what);
return -1;
}
} else {
got += ret;
buf[got] = '\0';
- if ((ret = func(driver, vm, buf, fd)) != 1)
+ if ((ret = func(conn, driver, vm, buf, fd)) != 1)
return ret;
}
}
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"Out of space while reading %s startup output", what);
return -1;
}
static int
-qemudCheckMonitorPrompt(struct qemud_driver *driver ATTRIBUTE_UNUSED,
+qemudCheckMonitorPrompt(virConnectPtr conn ATTRIBUTE_UNUSED,
+ struct qemud_driver *driver ATTRIBUTE_UNUSED,
struct qemud_vm *vm,
const char *output,
int fd)
return 0;
}
-static int qemudOpenMonitor(struct qemud_driver *driver, struct qemud_vm *vm, const char *monitor) {
+static int qemudOpenMonitor(virConnectPtr conn,
+ struct qemud_driver *driver,
+ struct qemud_vm *vm,
+ const char *monitor) {
int monfd;
char buf[1024];
int ret = -1;
if (!(monfd = open(monitor, O_RDWR))) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"Unable to open monitor path %s", monitor);
return -1;
}
if (qemudSetCloseExec(monfd) < 0) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"Unable to set monitor close-on-exec flag");
goto error;
}
if (qemudSetNonBlock(monfd) < 0) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"Unable to put monitor into non-blocking mode");
goto error;
}
- ret = qemudReadMonitorOutput(driver, vm, monfd,
+ ret = qemudReadMonitorOutput(conn,
+ driver, vm, monfd,
buf, sizeof(buf),
qemudCheckMonitorPrompt,
"monitor");
}
static int
-qemudOpenMonitorPath(struct qemud_driver *driver,
+qemudOpenMonitorPath(virConnectPtr conn,
+ struct qemud_driver *driver,
struct qemud_vm *vm,
const char *output,
int fd ATTRIBUTE_UNUSED)
if (qemudExtractMonitorPath(output, monitor, sizeof(monitor)) < 0)
return 1; /* keep reading */
- return qemudOpenMonitor(driver, vm, monitor);
+ return qemudOpenMonitor(conn, driver, vm, monitor);
}
-static int qemudWaitForMonitor(struct qemud_driver *driver, struct qemud_vm *vm) {
+static int qemudWaitForMonitor(virConnectPtr conn,
+ struct qemud_driver *driver,
+ struct qemud_vm *vm) {
char buf[1024]; /* Plenty of space to get startup greeting */
- int ret = qemudReadMonitorOutput(driver, vm, vm->stderr,
+ int ret = qemudReadMonitorOutput(conn,
+ driver, vm, vm->stderr,
buf, sizeof(buf),
qemudOpenMonitorPath,
"console");
qemudLog(QEMUD_WARN, "Unable to log VM console data: %s",
strerror(errno));
}
-
return ret;
}
return -1;
}
-static int qemudStartVMDaemon(struct qemud_driver *driver,
- struct qemud_vm *vm) {
+static int qemudStartVMDaemon(virConnectPtr conn,
+ struct qemud_driver *driver,
+ struct qemud_vm *vm) {
char **argv = NULL, **tmp;
int i;
char logfile[PATH_MAX];
if (qemudIsActiveVM(vm)) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"VM is already active");
return -1;
}
if (vm->def->vncPort < 0) {
int port = qemudNextFreeVNCPort(driver);
if (port < 0) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"Unable to find an unused VNC port");
return -1;
}
strlen(vm->def->name) + /* basename */
4 + /* suffix .log */
1 /* NULL */) > PATH_MAX) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"config file path too long: %s/%s.log",
driver->logDir, vm->def->name);
return -1;
strcat(logfile, ".log");
if (qemudEnsureDir(driver->logDir) < 0) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"cannot create log directory %s: %s",
driver->logDir, strerror(errno));
return -1;
if ((vm->logfile = open(logfile, O_CREAT | O_TRUNC | O_WRONLY,
S_IRUSR | S_IWUSR)) < 0) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"failed to create logfile %s: %s",
logfile, strerror(errno));
return -1;
}
- if (qemudBuildCommandLine(driver, vm, &argv) < 0) {
+ if (qemudBuildCommandLine(conn, driver, vm, &argv) < 0) {
close(vm->logfile);
vm->logfile = -1;
return -1;
qemudLog(QEMUD_WARN, "Unable to write argv to logfile %d: %s",
errno, strerror(errno));
- if (qemudExec(argv, &vm->pid, &vm->stdout, &vm->stderr) == 0) {
+ if (qemudExec(conn, argv, &vm->pid, &vm->stdout, &vm->stderr) == 0) {
vm->id = driver->nextvmid++;
vm->state = VIR_DOMAIN_RUNNING;
POLLIN | POLLERR | POLLHUP,
qemudDispatchVMEvent,
driver) < 0) {
- qemudShutdownVMDaemon(driver, vm);
+ qemudShutdownVMDaemon(conn, driver, vm);
return -1;
}
POLLIN | POLLERR | POLLHUP,
qemudDispatchVMEvent,
driver) < 0) {
- qemudShutdownVMDaemon(driver, vm);
+ qemudShutdownVMDaemon(conn, driver, vm);
return -1;
}
-
- if (qemudWaitForMonitor(driver, vm) < 0) {
- qemudShutdownVMDaemon(driver, vm);
+ if (qemudWaitForMonitor(conn, driver, vm) < 0) {
+ qemudShutdownVMDaemon(conn, driver, vm);
return -1;
}
}
-static int qemudShutdownVMDaemon(struct qemud_driver *driver, struct qemud_vm *vm) {
+static int qemudShutdownVMDaemon(virConnectPtr conn ATTRIBUTE_UNUSED,
+ struct qemud_driver *driver, struct qemud_vm *vm) {
if (!qemudIsActiveVM(vm))
return 0;
static int qemudDispatchVMLog(struct qemud_driver *driver, struct qemud_vm *vm, int fd) {
if (qemudVMData(driver, vm, fd) < 0)
- if (qemudShutdownVMDaemon(driver, vm) < 0)
+ if (qemudShutdownVMDaemon(NULL, driver, vm) < 0)
return -1;
return 0;
}
static int qemudDispatchVMFailure(struct qemud_driver *driver, struct qemud_vm *vm,
int fd ATTRIBUTE_UNUSED) {
- if (qemudShutdownVMDaemon(driver, vm) < 0)
+ if (qemudShutdownVMDaemon(NULL, driver, vm) < 0)
return -1;
return 0;
}
static int
-qemudBuildDnsmasqArgv(struct qemud_network *network,
+qemudBuildDnsmasqArgv(virConnectPtr conn,
+ struct qemud_network *network,
char ***argv) {
int i, len;
char buf[PATH_MAX];
free((*argv)[i]);
free(*argv);
}
- qemudReportError(NULL, NULL, NULL, VIR_ERR_NO_MEMORY, "dnsmasq argv");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, "dnsmasq argv");
return -1;
}
static int
-dhcpStartDhcpDaemon(struct qemud_network *network)
+dhcpStartDhcpDaemon(virConnectPtr conn,
+ struct qemud_network *network)
{
char **argv;
int ret, i;
if (network->def->ipAddress[0] == '\0') {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"cannot start dhcp daemon without IP address for server");
return -1;
}
argv = NULL;
- if (qemudBuildDnsmasqArgv(network, &argv) < 0)
+ if (qemudBuildDnsmasqArgv(conn, network, &argv) < 0)
return -1;
- ret = qemudExec(argv, &network->dnsmasqPid, NULL, NULL);
+ ret = qemudExec(conn, argv, &network->dnsmasqPid, NULL, NULL);
for (i = 0; argv[i]; i++)
free(argv[i]);
}
static int
-qemudAddIptablesRules(struct qemud_driver *driver,
+qemudAddIptablesRules(virConnectPtr conn,
+ struct qemud_driver *driver,
struct qemud_network *network) {
int err;
if (!driver->iptables && !(driver->iptables = iptablesContextNew())) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_NO_MEMORY, "iptables support");
+ qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, "iptables support");
return 1;
}
/* allow DHCP requests through to dnsmasq */
if ((err = iptablesAddTcpInput(driver->iptables, network->bridge, 67))) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"failed to add iptables rule to allow DHCP requests from '%s' : %s\n",
network->bridge, strerror(err));
goto err1;
}
if ((err = iptablesAddUdpInput(driver->iptables, network->bridge, 67))) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"failed to add iptables rule to allow DHCP requests from '%s' : %s\n",
network->bridge, strerror(err));
goto err2;
/* allow DNS requests through to dnsmasq */
if ((err = iptablesAddTcpInput(driver->iptables, network->bridge, 53))) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"failed to add iptables rule to allow DNS requests from '%s' : %s\n",
network->bridge, strerror(err));
goto err3;
}
if ((err = iptablesAddUdpInput(driver->iptables, network->bridge, 53))) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"failed to add iptables rule to allow DNS requests from '%s' : %s\n",
network->bridge, strerror(err));
goto err4;
/* Catch all rules to block forwarding to/from bridges */
if ((err = iptablesAddForwardRejectOut(driver->iptables, network->bridge))) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"failed to add iptables rule to block outbound traffic from '%s' : %s\n",
network->bridge, strerror(err));
goto err5;
}
if ((err = iptablesAddForwardRejectIn(driver->iptables, network->bridge))) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"failed to add iptables rule to block inbound traffic to '%s' : %s\n",
network->bridge, strerror(err));
goto err6;
/* Allow traffic between guests on the same bridge */
if ((err = iptablesAddForwardAllowCross(driver->iptables, network->bridge))) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"failed to add iptables rule to allow cross bridge traffic on '%s' : %s\n",
network->bridge, strerror(err));
goto err7;
network->def->network,
network->bridge,
network->def->forwardDev))) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"failed to add iptables rule to allow forwarding from '%s' : %s\n",
network->bridge, strerror(err));
goto err8;
network->def->network,
network->bridge,
network->def->forwardDev))) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"failed to add iptables rule to allow forwarding to '%s' : %s\n",
network->bridge, strerror(err));
goto err9;
if ((err = iptablesAddForwardMasquerade(driver->iptables,
network->def->network,
network->def->forwardDev))) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"failed to add iptables rule to enable masquerading : %s\n",
strerror(err));
goto err10;
#undef PROC_IP_FORWARD
}
-static int qemudStartNetworkDaemon(struct qemud_driver *driver,
- struct qemud_network *network) {
+static int qemudStartNetworkDaemon(virConnectPtr conn,
+ struct qemud_driver *driver,
+ struct qemud_network *network) {
const char *name;
int err;
if (qemudIsActiveNetwork(network)) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"network is already active");
return -1;
}
if (!driver->brctl && (err = brInit(&driver->brctl))) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"cannot initialize bridge support: %s", strerror(err));
return -1;
}
}
if ((err = brAddBridge(driver->brctl, name, network->bridge, sizeof(network->bridge)))) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"cannot create bridge '%s' : %s", name, strerror(err));
return -1;
}
if (network->def->forwardDelay &&
(err = brSetForwardDelay(driver->brctl, network->bridge, network->def->forwardDelay))) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"failed to set bridge forward delay to %d\n",
network->def->forwardDelay);
goto err_delbr;
}
if ((err = brSetForwardDelay(driver->brctl, network->bridge, network->def->disableSTP ? 0 : 1))) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"failed to set bridge STP to %s\n",
network->def->disableSTP ? "off" : "on");
goto err_delbr;
if (network->def->ipAddress[0] &&
(err = brSetInetAddress(driver->brctl, network->bridge, network->def->ipAddress))) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"cannot set IP address on bridge '%s' to '%s' : %s\n",
network->bridge, network->def->ipAddress, strerror(err));
goto err_delbr;
if (network->def->netmask[0] &&
(err = brSetInetNetmask(driver->brctl, network->bridge, network->def->netmask))) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"cannot set netmask on bridge '%s' to '%s' : %s\n",
network->bridge, network->def->netmask, strerror(err));
goto err_delbr;
if (network->def->ipAddress[0] &&
(err = brSetInterfaceUp(driver->brctl, network->bridge, 1))) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"failed to bring the bridge '%s' up : %s\n",
network->bridge, strerror(err));
goto err_delbr;
}
- if (!qemudAddIptablesRules(driver, network))
+ if (!qemudAddIptablesRules(conn, driver, network))
goto err_delbr1;
if (network->def->forward &&
!qemudEnableIpForwarding()) {
- qemudReportError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
"failed to enable IP forwarding : %s\n", strerror(err));
goto err_delbr2;
}
if (network->def->ranges &&
- dhcpStartDhcpDaemon(network) < 0)
+ dhcpStartDhcpDaemon(conn, network) < 0)
goto err_delbr2;
network->active = 1;
}
-static int qemudShutdownNetworkDaemon(struct qemud_driver *driver,
- struct qemud_network *network) {
+static int qemudShutdownNetworkDaemon(virConnectPtr conn ATTRIBUTE_UNUSED,
+ struct qemud_driver *driver,
+ struct qemud_network *network) {
int err;
qemudLog(QEMUD_INFO, "Shutting down network '%s'", network->def->name);
static int qemudGetVersion(virConnectPtr conn, unsigned long *version) {
struct qemud_driver *driver = (struct qemud_driver *)conn->privateData;
- if (qemudExtractVersion(driver) < 0)
+ if (qemudExtractVersion(conn, driver) < 0)
return -1;
*version = qemu_driver->qemuVersion;
return driver->nactivevms;
}
static virDomainPtr qemudDomainCreate(virConnectPtr conn, const char *xml,
- unsigned int flags ATTRIBUTE_UNUSED) {
+ unsigned int flags ATTRIBUTE_UNUSED) {
struct qemud_vm_def *def;
struct qemud_vm *vm;
virDomainPtr dom;
struct qemud_driver *driver = (struct qemud_driver *)conn->privateData;
- if (!(def = qemudParseVMDef(driver, xml, NULL)))
+ if (!(def = qemudParseVMDef(conn, driver, xml, NULL)))
return NULL;
- if (!(vm = qemudAssignVMDef(driver, def))) {
+ if (!(vm = qemudAssignVMDef(conn, driver, def))) {
qemudFreeVMDef(def);
return NULL;
}
- if (qemudStartVMDaemon(driver, vm) < 0) {
+ if (qemudStartVMDaemon(conn, driver, vm) < 0) {
qemudRemoveInactiveVM(driver, vm);
return NULL;
}
return -1;
}
- ret = qemudShutdownVMDaemon(driver, vm);
+ ret = qemudShutdownVMDaemon(dom->conn, driver, vm);
virFreeDomain(dom->conn, dom);
return ret;
}
return NULL;
}
- return qemudGenerateXML(driver, vm, vm->def, 1);
+ return qemudGenerateXML(dom->conn, driver, vm, vm->def, 1);
}
return -1;
}
- return qemudStartVMDaemon(driver, vm);
+ return qemudStartVMDaemon(dom->conn, driver, vm);
}
struct qemud_vm *vm;
virDomainPtr dom;
- if (!(def = qemudParseVMDef(driver, xml, NULL)))
+ if (!(def = qemudParseVMDef(conn, driver, xml, NULL)))
return NULL;
- if (!(vm = qemudAssignVMDef(driver, def))) {
+ if (!(vm = qemudAssignVMDef(conn, driver, def))) {
qemudFreeVMDef(def);
return NULL;
}
- if (qemudSaveVMDef(driver, vm, def) < 0) {
+ if (qemudSaveVMDef(conn, driver, vm, def) < 0) {
qemudRemoveInactiveVM(driver, vm);
return NULL;
}
return -1;
}
- if (qemudDeleteConfig(driver, vm->configFile, vm->def->name) < 0)
+ if (qemudDeleteConfig(dom->conn, driver, vm->configFile, vm->def->name) < 0)
return -1;
if (unlink(vm->autostartLink) < 0 && errno != ENOENT && errno != ENOTDIR)
struct qemud_network *network;
virNetworkPtr net;
- if (!(def = qemudParseNetworkDef(driver, xml, NULL)))
+ if (!(def = qemudParseNetworkDef(conn, driver, xml, NULL)))
return NULL;
- if (!(network = qemudAssignNetworkDef(driver, def))) {
+ if (!(network = qemudAssignNetworkDef(conn, driver, def))) {
qemudFreeNetworkDef(def);
return NULL;
}
- if (qemudStartNetworkDaemon(driver, network) < 0) {
+ if (qemudStartNetworkDaemon(conn, driver, network) < 0) {
qemudRemoveInactiveNetwork(driver, network);
return NULL;
}
struct qemud_network *network;
virNetworkPtr net;
- if (!(def = qemudParseNetworkDef(driver, xml, NULL)))
+ if (!(def = qemudParseNetworkDef(conn, driver, xml, NULL)))
return NULL;
- if (!(network = qemudAssignNetworkDef(driver, def))) {
+ if (!(network = qemudAssignNetworkDef(conn, driver, def))) {
qemudFreeNetworkDef(def);
return NULL;
}
- if (qemudSaveNetworkDef(driver, network, def) < 0) {
+ if (qemudSaveNetworkDef(conn, driver, network, def) < 0) {
qemudRemoveInactiveNetwork(driver, network);
return NULL;
}
return -1;
}
- if (qemudDeleteConfig(driver, network->configFile, network->def->name) < 0)
+ if (qemudDeleteConfig(net->conn, driver, network->configFile, network->def->name) < 0)
return -1;
if (unlink(network->autostartLink) < 0 && errno != ENOENT && errno != ENOTDIR)
return -1;
}
- return qemudStartNetworkDaemon(driver, network);
+ return qemudStartNetworkDaemon(net->conn, driver, network);
}
static int qemudNetworkDestroy(virNetworkPtr net) {
return -1;
}
- ret = qemudShutdownNetworkDaemon(driver, network);
+ ret = qemudShutdownNetworkDaemon(net->conn, driver, network);
virFreeNetwork(net->conn, net);
return NULL;
}
- return qemudGenerateNetworkXML(driver, network, network->def);
+ return qemudGenerateNetworkXML(net->conn, driver, network, network->def);
}
static char *qemudNetworkGetBridgeName(virNetworkPtr net) {