#endif /* VBOX_API_VERSION >= 3001 */
-#define vboxError(conn, code, ...) \
- virReportErrorHelper(conn, VIR_FROM_VBOX, code, __FILE__, \
+#define vboxError(code, ...) \
+ virReportErrorHelper(NULL, VIR_FROM_VBOX, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
#define DEBUGPRUnichar(msg, strUtf16) \
return NULL;
}
-static int vboxInitialize(virConnectPtr conn, vboxGlobalData *data) {
+static int vboxInitialize(vboxGlobalData *data) {
/* Get the API table for out version, g_pVBoxFuncs is for the oldest
version of the API that we support so we cannot use that. */
data->pFuncs->pfnGetEventQueue(&data->vboxQueue);
if (data->vboxQueue == NULL) {
- vboxError(conn, VIR_ERR_INTERNAL_ERROR, "nsIEventQueue object is null");
+ vboxError(VIR_ERR_INTERNAL_ERROR, "nsIEventQueue object is null");
goto cleanup;
}
#endif /* !(VBOX_XPCOMC_VERSION == 0x00010000U) */
if (data->vboxObj == NULL) {
- vboxError(conn, VIR_ERR_INTERNAL_ERROR, "IVirtualBox object is null");
+ vboxError(VIR_ERR_INTERNAL_ERROR, "IVirtualBox object is null");
goto cleanup;
}
if (data->vboxSession == NULL) {
- vboxError(conn, VIR_ERR_INTERNAL_ERROR, "ISession object is null");
+ vboxError(VIR_ERR_INTERNAL_ERROR, "ISession object is null");
goto cleanup;
}
return -1;
}
-static int vboxExtractVersion(virConnectPtr conn, vboxGlobalData *data) {
+static int vboxExtractVersion(vboxGlobalData *data) {
int ret = -1;
PRUnichar *versionUtf16 = NULL;
nsresult rc;
}
if (ret != 0)
- vboxError(conn, VIR_ERR_INTERNAL_ERROR,"%s",
+ vboxError(VIR_ERR_INTERNAL_ERROR,"%s",
"Cound not extract VirtualBox version");
return ret;
return VIR_DRV_OPEN_DECLINED;
if (conn->uri->path == NULL || STREQ(conn->uri->path, "")) {
- vboxError(conn, VIR_ERR_INTERNAL_ERROR, "%s",
+ vboxError(VIR_ERR_INTERNAL_ERROR, "%s",
_("no VirtualBox driver path specified (try vbox:///session)"));
return VIR_DRV_OPEN_ERROR;
}
if (uid != 0) {
if (STRNEQ (conn->uri->path, "/session")) {
- vboxError(conn, VIR_ERR_INTERNAL_ERROR,
+ vboxError(VIR_ERR_INTERNAL_ERROR,
_("unknown driver path '%s' specified (try vbox:///session)"), conn->uri->path);
return VIR_DRV_OPEN_ERROR;
}
} else { /* root */
if (STRNEQ (conn->uri->path, "/system") &&
STRNEQ (conn->uri->path, "/session")) {
- vboxError(conn, VIR_ERR_INTERNAL_ERROR,
+ vboxError(VIR_ERR_INTERNAL_ERROR,
_("unknown driver path '%s' specified (try vbox:///system)"), conn->uri->path);
return VIR_DRV_OPEN_ERROR;
}
}
if (!(data->caps = vboxCapsInit()) ||
- vboxInitialize(conn, data) < 0 ||
- vboxExtractVersion(conn, data) < 0) {
+ vboxInitialize(data) < 0 ||
+ vboxExtractVersion(data) < 0) {
vboxUninitialize(data);
return VIR_DRV_OPEN_ERROR;
}
rc = data->vboxObj->vtbl->GetMachines(data->vboxObj, &machineCnt, &machines);
if (NS_FAILED(rc)) {
- vboxError(conn, VIR_ERR_INTERNAL_ERROR,"%s, rc=%08x",
+ vboxError(VIR_ERR_INTERNAL_ERROR,"%s, rc=%08x",
"Could not get list of Domains",(unsigned)rc);
goto cleanup;
}
rc = data->vboxObj->vtbl->GetMachines(data->vboxObj, &machineCnt, &machines);
if (NS_FAILED(rc)) {
- vboxError(conn, VIR_ERR_INTERNAL_ERROR,"%s, rc=%08x",
+ vboxError(VIR_ERR_INTERNAL_ERROR,"%s, rc=%08x",
"Could not get number of Domains",(unsigned)rc);
goto cleanup;
}
/* Internal vbox IDs start from 0, the public libvirt ID
* starts from 1, so refuse id==0, and adjust the rest*/
if (id == 0) {
- vboxError(conn, VIR_ERR_NO_DOMAIN,
+ vboxError(VIR_ERR_NO_DOMAIN,
_("no domain with matching id %d"), id);
return NULL;
}
rc = data->vboxObj->vtbl->GetMachines(data->vboxObj, &machineCnt, &machines);
if (NS_FAILED(rc)) {
- vboxError(conn, VIR_ERR_INTERNAL_ERROR,"%s, rc=%08x",
+ vboxError(VIR_ERR_INTERNAL_ERROR,"%s, rc=%08x",
"Could not get list of machines",(unsigned)rc);
return NULL;
}
rc = data->vboxObj->vtbl->GetMachines(data->vboxObj, &machineCnt, &machines);
if (NS_FAILED(rc)) {
- vboxError(conn, VIR_ERR_INTERNAL_ERROR,"%s, rc=%08x",
+ vboxError(VIR_ERR_INTERNAL_ERROR,"%s, rc=%08x",
"Could not get list of machines",(unsigned)rc);
return NULL;
}
rc = data->vboxObj->vtbl->GetMachines(data->vboxObj, &machineCnt, &machines);
if (NS_FAILED(rc)) {
- vboxError(conn, VIR_ERR_INTERNAL_ERROR,"%s, rc=%08x",
+ vboxError(VIR_ERR_INTERNAL_ERROR,"%s, rc=%08x",
"Could not get list of machines",(unsigned)rc);
return NULL;
}
rc = data->vboxObj->vtbl->GetMachines(data->vboxObj, &machineCnt, &machines);
if (NS_FAILED(rc)) {
- vboxError(dom->conn, VIR_ERR_INTERNAL_ERROR,"%s, rc=%08x",
+ vboxError(VIR_ERR_INTERNAL_ERROR,"%s, rc=%08x",
"Could not get list of machines",(unsigned)rc);
return ret;
}
vboxIIDFromUUID(dom->uuid, iid);
rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid, &machine);
if (NS_FAILED(rc)) {
- vboxError(dom->conn, VIR_ERR_INVALID_DOMAIN,
+ vboxError(VIR_ERR_INVALID_DOMAIN,
"no domain with matching id %d", dom->id);
goto cleanup;
}
VBOX_RELEASE(console);
ret = 0;
} else {
- vboxError(dom->conn, VIR_ERR_OPERATION_FAILED,
+ vboxError(VIR_ERR_OPERATION_FAILED,
"%s", "error while suspend the domain");
goto cleanup;
}
data->vboxSession->vtbl->Close(data->vboxSession);
} else {
- vboxError(dom->conn, VIR_ERR_OPERATION_FAILED,
+ vboxError(VIR_ERR_OPERATION_FAILED,
"%s", "machine not in running state to suspend it");
goto cleanup;
}
vboxIIDFromUUID(dom->uuid, iid);
rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid, &machine);
if (NS_FAILED(rc)) {
- vboxError(dom->conn, VIR_ERR_INVALID_DOMAIN,
+ vboxError(VIR_ERR_INVALID_DOMAIN,
"no domain with matching id %d", dom->id);
goto cleanup;
}
VBOX_RELEASE(console);
ret = 0;
} else {
- vboxError(dom->conn, VIR_ERR_OPERATION_FAILED,
+ vboxError(VIR_ERR_OPERATION_FAILED,
"%s", "error while resuming the domain");
goto cleanup;
}
data->vboxSession->vtbl->Close(data->vboxSession);
} else {
- vboxError(dom->conn, VIR_ERR_OPERATION_FAILED,
+ vboxError(VIR_ERR_OPERATION_FAILED,
"%s", "machine not paused, so can't resume it");
goto cleanup;
}
vboxIIDFromUUID(dom->uuid, iid);
rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid, &machine);
if (NS_FAILED(rc)) {
- vboxError(dom->conn, VIR_ERR_INVALID_DOMAIN,
+ vboxError(VIR_ERR_INVALID_DOMAIN,
"no domain with matching id %d", dom->id);
goto cleanup;
}
machine->vtbl->GetState(machine, &state);
if (state == MachineState_Paused) {
- vboxError(dom->conn, VIR_ERR_OPERATION_FAILED,
+ vboxError(VIR_ERR_OPERATION_FAILED,
"%s", "machine paused, so can't power it down");
goto cleanup;
} else if (state == MachineState_PoweredOff) {
- vboxError(dom->conn, VIR_ERR_OPERATION_FAILED,
+ vboxError(VIR_ERR_OPERATION_FAILED,
"%s", "machine already powered down");
goto cleanup;
}
vboxIIDFromUUID(dom->uuid, iid);
rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid, &machine);
if (NS_FAILED(rc)) {
- vboxError(dom->conn, VIR_ERR_INVALID_DOMAIN,
+ vboxError(VIR_ERR_INVALID_DOMAIN,
"no domain with matching id %d", dom->id);
goto cleanup;
}
}
data->vboxSession->vtbl->Close(data->vboxSession);
} else {
- vboxError(dom->conn, VIR_ERR_OPERATION_FAILED,
+ vboxError(VIR_ERR_OPERATION_FAILED,
"%s", "machine not running, so can't reboot it");
goto cleanup;
}
vboxIIDFromUUID(dom->uuid, iid);
rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid, &machine);
if (NS_FAILED(rc)) {
- vboxError(dom->conn, VIR_ERR_INVALID_DOMAIN,
+ vboxError(VIR_ERR_INVALID_DOMAIN,
"no domain with matching id %d", dom->id);
goto cleanup;
}
machine->vtbl->GetState(machine, &state);
if (state == MachineState_PoweredOff) {
- vboxError(dom->conn, VIR_ERR_OPERATION_FAILED,
+ vboxError(VIR_ERR_OPERATION_FAILED,
"%s", "machine already powered down");
goto cleanup;
}
vboxIIDFromUUID(dom->uuid, iid);
rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid, &machine);
if (NS_FAILED(rc)) {
- vboxError(dom->conn, VIR_ERR_INVALID_DOMAIN,
+ vboxError(VIR_ERR_INVALID_DOMAIN,
"no domain with matching id %d", dom->id);
goto cleanup;
}
machine->vtbl->GetState(machine, &state);
if (state != MachineState_PoweredOff) {
- vboxError(dom->conn, VIR_ERR_OPERATION_FAILED,
+ vboxError(VIR_ERR_OPERATION_FAILED,
"%s", "memory size can't be changed unless domain is powered down");
goto cleanup;
}
machine->vtbl->SaveSettings(machine);
ret = 0;
} else {
- vboxError(dom->conn, VIR_ERR_INTERNAL_ERROR,"%s:%lu Kb, rc=%08x",
+ vboxError(VIR_ERR_INTERNAL_ERROR, "%s:%lu Kb, rc=%08x",
"could not set the memory size of the domain to",
memory, (unsigned)rc);
}
rc = data->vboxObj->vtbl->GetMachines(data->vboxObj, &machineCnt, &machines);
if (NS_FAILED(rc)) {
- vboxError(NULL, VIR_ERR_INTERNAL_ERROR,"%s, rc=%08x",
- "Could not get list of machines",(unsigned)rc);
+ vboxError(VIR_ERR_INTERNAL_ERROR, "%s, rc=%08x",
+ "Could not get list of machines", (unsigned)rc);
goto cleanup;
}
machine->vtbl->SaveSettings(machine);
ret = 0;
} else {
- vboxError(dom->conn, VIR_ERR_INTERNAL_ERROR, "%s: %u, rc=%08x",
+ vboxError(VIR_ERR_INTERNAL_ERROR, "%s: %u, rc=%08x",
"could not set the number of cpus of the domain to",
CPUCount, (unsigned)rc);
}
VBOX_RELEASE(machine);
} else {
- vboxError(dom->conn, VIR_ERR_INVALID_DOMAIN,
+ vboxError(VIR_ERR_INVALID_DOMAIN,
"no domain with matching id %d", dom->id);
}
} else {
- vboxError(dom->conn, VIR_ERR_INVALID_DOMAIN,
+ vboxError(VIR_ERR_INVALID_DOMAIN,
"can't open session to the domain with id %d", dom->id);
}
data->vboxSession->vtbl->Close(data->vboxSession);
maxPortPerInst,
maxSlotPerPort);
if (!def->disks[diskCount]->dst) {
- vboxError(dom->conn, VIR_ERR_INTERNAL_ERROR,
+ vboxError(VIR_ERR_INTERNAL_ERROR,
"%s: controller instance:%u, port:%d, slot:%d",
"Could not generate medium name for the disk at",
deviceInst, devicePort, deviceSlot);
rc = data->vboxObj->vtbl->GetMachines(data->vboxObj, &machineCnt, &machines);
if (NS_FAILED(rc)) {
- vboxError(conn, VIR_ERR_INTERNAL_ERROR,"%s, rc=%08x",
+ vboxError(VIR_ERR_INTERNAL_ERROR,"%s, rc=%08x",
"Could not get list of Defined Domains",(unsigned)rc);
goto cleanup;
}
rc = data->vboxObj->vtbl->GetMachines(data->vboxObj, &machineCnt, &machines);
if (NS_FAILED(rc)) {
- vboxError(conn, VIR_ERR_INTERNAL_ERROR,"%s, rc=%08x",
+ vboxError(VIR_ERR_INTERNAL_ERROR,"%s, rc=%08x",
"Could not get number of Defined Domains",(unsigned)rc);
goto cleanup;
}
int i = 0;
if (!dom->name) {
- vboxError(dom->conn, VIR_ERR_INTERNAL_ERROR,"%s",
+ vboxError(VIR_ERR_INTERNAL_ERROR, "%s",
"Error while reading the domain name");
goto cleanup;
}
rc = data->vboxObj->vtbl->GetMachines(data->vboxObj, &machineCnt, &machines);
if (NS_FAILED(rc)) {
- vboxError(dom->conn, VIR_ERR_INTERNAL_ERROR,"%s, rc=%08x",
+ vboxError(VIR_ERR_INTERNAL_ERROR, "%s, rc=%08x",
"Could not get list of machines",(unsigned)rc);
goto cleanup;
}
if (valueDisplayUtf8) {
sdlDisplay = strdup(valueDisplayUtf8);
if (sdlDisplay == NULL) {
- vboxError(dom->conn, VIR_ERR_SYSTEM_ERROR, "%s", "strdup failed");
+ virReportOOMError();
/* just don't go to cleanup yet as it is ok to have
* sdlDisplay as NULL and we check it below if it
* exist and then only use it there
if (valueDisplayUtf8) {
guiDisplay = strdup(valueDisplayUtf8);
if (guiDisplay == NULL) {
- vboxError(dom->conn, VIR_ERR_SYSTEM_ERROR, "%s", "strdup failed");
+ virReportOOMError();
/* just don't go to cleanup yet as it is ok to have
* guiDisplay as NULL and we check it below if it
* exist and then only use it there
env,
&progress );
if (NS_FAILED(rc)) {
- vboxError(dom->conn, VIR_ERR_OPERATION_FAILED,
+ vboxError(VIR_ERR_OPERATION_FAILED,
"%s", "openremotesession failed, domain can't be started");
ret = -1;
} else {
data->vboxSession->vtbl->Close(data->vboxSession);
} else {
- vboxError(dom->conn, VIR_ERR_OPERATION_FAILED,
+ vboxError(VIR_ERR_OPERATION_FAILED,
"%s", "machine is not in poweroff|saved|"
"aborted state, so couldn't start it");
ret = -1;
VBOX_UTF16_FREE(machineNameUtf16);
if (NS_FAILED(rc)) {
- vboxError(conn, VIR_ERR_INTERNAL_ERROR,"%s, rc=%08x",
- "could not define a domain",(unsigned)rc);
+ vboxError(VIR_ERR_INTERNAL_ERROR, "%s, rc=%08x",
+ "could not define a domain", (unsigned)rc);
goto cleanup;
}
rc = machine->vtbl->SetMemorySize(machine, def->memory / 1024);
if (NS_FAILED(rc)) {
- vboxError(conn, VIR_ERR_INTERNAL_ERROR,"%s:%lu Kb, rc=%08x",
+ vboxError(VIR_ERR_INTERNAL_ERROR, "%s:%lu Kb, rc=%08x",
"could not set the memory size of the domain to",
def->memory, (unsigned)rc);
}
rc = machine->vtbl->SetCPUCount(machine, def->vcpus);
if (NS_FAILED(rc)) {
- vboxError(conn, VIR_ERR_INTERNAL_ERROR,"%s:%lu, rc=%08x",
+ vboxError(VIR_ERR_INTERNAL_ERROR, "%s:%lu, rc=%08x",
"could not set the number of virtual CPUs to",
def->vcpus, (unsigned)rc);
}
(1 << VIR_DOMAIN_FEATURE_PAE));
#endif /* VBOX_API_VERSION >= 3001 */
if (NS_FAILED(rc)) {
- vboxError(conn, VIR_ERR_INTERNAL_ERROR,"%s:%s, rc=%08x",
+ vboxError(VIR_ERR_INTERNAL_ERROR, "%s:%s, rc=%08x",
"could not change PAE status to",
((def->features) & (1 << VIR_DOMAIN_FEATURE_PAE))
? "Enabled" : "Disabled", (unsigned)rc);
rc = bios->vtbl->SetACPIEnabled(bios, (def->features) &
(1 << VIR_DOMAIN_FEATURE_ACPI));
if (NS_FAILED(rc)) {
- vboxError(conn, VIR_ERR_INTERNAL_ERROR,"%s:%s, rc=%08x",
+ vboxError(VIR_ERR_INTERNAL_ERROR, "%s:%s, rc=%08x",
"could not change ACPI status to",
((def->features) & (1 << VIR_DOMAIN_FEATURE_ACPI))
? "Enabled" : "Disabled", (unsigned)rc);
rc = bios->vtbl->SetIOAPICEnabled(bios, (def->features) &
(1 << VIR_DOMAIN_FEATURE_APIC));
if (NS_FAILED(rc)) {
- vboxError(conn, VIR_ERR_INTERNAL_ERROR,"%s:%s, rc=%08x",
+ vboxError(VIR_ERR_INTERNAL_ERROR,"%s:%s, rc=%08x",
"could not change APIC status to",
((def->features) & (1 << VIR_DOMAIN_FEATURE_APIC))
? "Enabled" : "Disabled", (unsigned)rc);
/* Register the machine before attaching other devices to it */
rc = data->vboxObj->vtbl->RegisterMachine(data->vboxObj, machine);
if (NS_FAILED(rc)) {
- vboxError(conn, VIR_ERR_INTERNAL_ERROR,"%s, rc=%08x",
- "could not define a domain",(unsigned)rc);
+ vboxError(VIR_ERR_INTERNAL_ERROR, "%s, rc=%08x",
+ "could not define a domain", (unsigned)rc);
goto cleanup;
}
if (dvdImage) {
rc = dvdImage->vtbl->imedium.GetId((IMedium *)dvdImage, &dvduuid);
if (NS_FAILED(rc)) {
- vboxError(conn, VIR_ERR_INTERNAL_ERROR,"%s:%s, rc=%08x",
+ vboxError(VIR_ERR_INTERNAL_ERROR, "%s:%s, rc=%08x",
"can't get the uuid of the file to be attached to cdrom",
def->disks[i]->src, (unsigned)rc);
} else {
rc = dvdDrive->vtbl->MountImage(dvdDrive, dvduuid);
if (NS_FAILED(rc)) {
- vboxError(conn, VIR_ERR_INTERNAL_ERROR,"%s:%s, rc=%08x",
+ vboxError(VIR_ERR_INTERNAL_ERROR, "%s:%s, rc=%08x",
"could not attach the file to cdrom",
def->disks[i]->src, (unsigned)rc);
} else {
if (hardDisk) {
rc = hardDisk->vtbl->imedium.GetId((IMedium *)hardDisk, &hdduuid);
if (NS_FAILED(rc)) {
- vboxError(conn, VIR_ERR_INTERNAL_ERROR,"%s:%s, rc=%08x",
+ vboxError(VIR_ERR_INTERNAL_ERROR, "%s:%s, rc=%08x",
"can't get the uuid of the file to be attached as harddisk",
def->disks[i]->src, (unsigned)rc);
} else {
VBOX_UTF16_FREE(hddcnameUtf16);
if (NS_FAILED(rc)) {
- vboxError(conn, VIR_ERR_INTERNAL_ERROR,"%s:%s, rc=%08x",
+ vboxError(VIR_ERR_INTERNAL_ERROR, "%s:%s, rc=%08x",
"could not attach the file as harddisk",
def->disks[i]->src, (unsigned)rc);
} else {
if (floppyImage) {
rc = floppyImage->vtbl->imedium.GetId((IMedium *)floppyImage, &fduuid);
if (NS_FAILED(rc)) {
- vboxError(conn, VIR_ERR_INTERNAL_ERROR,"%s:%s, rc=%08x",
+ vboxError(VIR_ERR_INTERNAL_ERROR, "%s:%s, rc=%08x",
"can't get the uuid of the file to be attached to floppy drive",
def->disks[i]->src, (unsigned)rc);
} else {
rc = floppyDrive->vtbl->MountImage(floppyDrive, fduuid);
if (NS_FAILED(rc)) {
- vboxError(conn, VIR_ERR_INTERNAL_ERROR,"%s:%s, rc=%08x",
+ vboxError(VIR_ERR_INTERNAL_ERROR, "%s:%s, rc=%08x",
"could not attach the file to floppy drive",
def->disks[i]->src, (unsigned)rc);
} else {
}
if (!medium) {
- vboxError(conn, VIR_ERR_INTERNAL_ERROR,"%s:%s, rc=%08x",
+ vboxError(VIR_ERR_INTERNAL_ERROR, "%s:%s, rc=%08x",
"Failed to attach the following disk/dvd/floppy to the machine",
def->disks[i]->src, (unsigned)rc);
VBOX_UTF16_FREE(mediumFileUtf16);
rc = medium->vtbl->GetId(medium, &mediumUUID);
if (NS_FAILED(rc)) {
- vboxError(conn, VIR_ERR_INTERNAL_ERROR,"%s:%s, rc=%08x",
+ vboxError(VIR_ERR_INTERNAL_ERROR, "%s:%s, rc=%08x",
"can't get the uuid of the file to be attached as harddisk/dvd/floppy",
def->disks[i]->src, (unsigned)rc);
VBOX_RELEASE(medium);
&deviceInst,
&devicePort,
&deviceSlot)) {
- vboxError(conn, VIR_ERR_INTERNAL_ERROR,"%s:%s, rc=%08x",
+ vboxError(VIR_ERR_INTERNAL_ERROR, "%s:%s, rc=%08x",
"can't get the port/slot number of harddisk/dvd/floppy to be attached",
def->disks[i]->src, (unsigned)rc);
VBOX_RELEASE(medium);
mediumUUID);
if (NS_FAILED(rc)) {
- vboxError(conn, VIR_ERR_INTERNAL_ERROR,"%s:%s, rc=%08x",
+ vboxError(VIR_ERR_INTERNAL_ERROR, "%s:%s, rc=%08x",
"could not attach the file as harddisk/dvd/floppy",
def->disks[i]->src, (unsigned)rc);
} else {
machine->vtbl->DeleteSettings(machine);
ret = 0;
} else {
- vboxError(dom->conn, VIR_ERR_INTERNAL_ERROR,"%s, rc=%08x",
+ vboxError(VIR_ERR_INTERNAL_ERROR, "%s, rc=%08x",
"could not delete the domain", (unsigned)rc);
}
rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid, &machine);
if (NS_FAILED(rc)) {
- vboxError(dom->conn, VIR_ERR_INVALID_DOMAIN,"no domain with matching uuid");
+ vboxError(VIR_ERR_INVALID_DOMAIN, "no domain with matching uuid");
goto cleanup;
}
if (dvdImage) {
rc = dvdImage->vtbl->imedium.GetId((IMedium *)dvdImage, &dvduuid);
if (NS_FAILED(rc)) {
- vboxError(dom->conn, VIR_ERR_INTERNAL_ERROR,"%s:%s, rc=%08x",
+ vboxError(VIR_ERR_INTERNAL_ERROR, "%s:%s, rc=%08x",
"can't get the uuid of the file to be attached to cdrom",
dev->data.disk->src, (unsigned)rc);
} else {
dvdDrive->vtbl->Unmount(dvdDrive);
rc = dvdDrive->vtbl->MountImage(dvdDrive, dvduuid);
if (NS_FAILED(rc)) {
- vboxError(dom->conn, VIR_ERR_INTERNAL_ERROR,"%s:%s, rc=%08x",
+ vboxError(VIR_ERR_INTERNAL_ERROR, "%s:%s, rc=%08x",
"could not attach the file to cdrom",
dev->data.disk->src, (unsigned)rc);
} else {
if (floppyImage) {
rc = floppyImage->vtbl->imedium.GetId((IMedium *)floppyImage, &fduuid);
if (NS_FAILED(rc)) {
- vboxError(dom->conn, VIR_ERR_INTERNAL_ERROR,"%s:%s, rc=%08x",
+ vboxError(VIR_ERR_INTERNAL_ERROR, "%s:%s, rc=%08x",
"can't get the uuid of the file to be attached to floppy drive",
dev->data.disk->src, (unsigned)rc);
} else {
rc = floppyDrive->vtbl->MountImage(floppyDrive, fduuid);
if (NS_FAILED(rc)) {
- vboxError(dom->conn, VIR_ERR_INTERNAL_ERROR,"%s:%s, rc=%08x",
+ vboxError(VIR_ERR_INTERNAL_ERROR, "%s:%s, rc=%08x",
"could not attach the file to floppy drive",
dev->data.disk->src, (unsigned)rc);
} else {
static int vboxDomainAttachDeviceFlags(virDomainPtr dom, const char *xml,
unsigned int flags) {
if (flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG) {
- vboxError(dom->conn, VIR_ERR_OPERATION_INVALID, "%s",
+ vboxError(VIR_ERR_OPERATION_INVALID, "%s",
_("cannot modify the persistent configuration of a domain"));
return -1;
}
static int vboxDomainUpdateDeviceFlags(virDomainPtr dom, const char *xml,
unsigned int flags) {
if (flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG) {
- vboxError(dom->conn, VIR_ERR_OPERATION_INVALID, "%s",
+ vboxError(VIR_ERR_OPERATION_INVALID, "%s",
_("cannot modify the persistent configuration of a domain"));
return -1;
}
rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid, &machine);
if (NS_FAILED(rc)) {
- vboxError(dom->conn, VIR_ERR_INVALID_DOMAIN, "no domain with matching uuid");
+ vboxError(VIR_ERR_INVALID_DOMAIN, "no domain with matching uuid");
goto cleanup;
}
if (dvdDrive) {
rc = dvdDrive->vtbl->Unmount(dvdDrive);
if (NS_FAILED(rc)) {
- vboxError(dom->conn, VIR_ERR_INTERNAL_ERROR,"%s, rc=%08x",
+ vboxError(VIR_ERR_INTERNAL_ERROR, "%s, rc=%08x",
"could not de-attach the mounted ISO",
(unsigned)rc);
} else {
if (enabled) {
rc = floppyDrive->vtbl->Unmount(floppyDrive);
if (NS_FAILED(rc)) {
- vboxError(dom->conn, VIR_ERR_INTERNAL_ERROR,"%s, rc=%08x",
+ vboxError(VIR_ERR_INTERNAL_ERROR, "%s, rc=%08x",
"could not attach the file to floppy drive",
(unsigned)rc);
} else {
static int vboxDomainDetachDeviceFlags(virDomainPtr dom, const char *xml,
unsigned int flags) {
if (flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG) {
- vboxError(dom->conn, VIR_ERR_OPERATION_INVALID, "%s",
+ vboxError(VIR_ERR_OPERATION_INVALID, "%s",
_("cannot modify the persistent configuration of a domain"));
return -1;
}
rc = machine->vtbl->GetSnapshotCount(machine, &count);
if (NS_FAILED(rc)) {
- vboxError(dom->conn, VIR_ERR_INTERNAL_ERROR,
+ vboxError(VIR_ERR_INTERNAL_ERROR,
_("could not get snapshot count for domain %s"),
dom->name);
goto error;
rc = machine->vtbl->GetSnapshot(machine, NULL, list);
if (NS_FAILED(rc) || !list[0]) {
- vboxError(dom->conn, VIR_ERR_INTERNAL_ERROR,
+ vboxError(VIR_ERR_INTERNAL_ERROR,
_("could not get root snapshot for domain %s"),
dom->name);
goto error;
unsigned int i;
if (!list[next]) {
- vboxError(dom->conn, VIR_ERR_INTERNAL_ERROR,
+ vboxError(VIR_ERR_INTERNAL_ERROR,
_("unexpected number of snapshots < %u"), count);
goto error;
}
rc = list[next]->vtbl->GetChildren(list[next], &childrenCount,
&children);
if (NS_FAILED(rc)) {
- vboxError(dom->conn, VIR_ERR_INTERNAL_ERROR,
+ vboxError(VIR_ERR_INTERNAL_ERROR,
"%s", _("could not get children snapshots"));
goto error;
}
if (!children[i])
continue;
if (top == count) {
- vboxError(dom->conn, VIR_ERR_INTERNAL_ERROR,
+ vboxError(VIR_ERR_INTERNAL_ERROR,
_("unexpected number of snapshots > %u"), count);
goto error;
}
rc = snapshots[i]->vtbl->GetName(snapshots[i], &nameUtf16);
if (NS_FAILED(rc) || !nameUtf16) {
- vboxError(dom->conn, VIR_ERR_INTERNAL_ERROR,
+ vboxError(VIR_ERR_INTERNAL_ERROR,
"%s", _("could not get snapshot name"));
goto cleanup;
}
}
if (!snapshot) {
- vboxError(dom->conn, VIR_ERR_OPERATION_INVALID,
+ vboxError(VIR_ERR_OPERATION_INVALID,
_("domain %s has no snapshots with name %s"),
dom->name, name);
goto cleanup;
vboxIIDFromUUID(dom->uuid, domiid);
rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, domiid, &machine);
if (NS_FAILED(rc) || !machine) {
- vboxError(dom->conn, VIR_ERR_INVALID_DOMAIN, "%s",
+ vboxError(VIR_ERR_INVALID_DOMAIN, "%s",
_("no domain with matching UUID"));
goto cleanup;
}
rc = machine->vtbl->GetState(machine, &state);
if (NS_FAILED(rc)) {
- vboxError(dom->conn, VIR_ERR_INTERNAL_ERROR, "%s",
+ vboxError(VIR_ERR_INTERNAL_ERROR, "%s",
_("could not get domain state"));
goto cleanup;
}
if (NS_SUCCEEDED(rc))
rc = data->vboxSession->vtbl->GetConsole(data->vboxSession, &console);
if (NS_FAILED(rc)) {
- vboxError(dom->conn, VIR_ERR_INTERNAL_ERROR,
+ vboxError(VIR_ERR_INTERNAL_ERROR,
_("could not open VirtualBox session with domain %s"),
dom->name);
goto cleanup;
rc = console->vtbl->TakeSnapshot(console, name, description, &progress);
if (NS_FAILED(rc) || !progress) {
- vboxError(dom->conn, VIR_ERR_INTERNAL_ERROR,
+ vboxError(VIR_ERR_INTERNAL_ERROR,
_("could not take snapshot of domain %s"), dom->name);
goto cleanup;
}
progress->vtbl->WaitForCompletion(progress, -1);
progress->vtbl->GetResultCode(progress, &result);
if (NS_FAILED(result)) {
- vboxError(dom->conn, VIR_ERR_INTERNAL_ERROR,
+ vboxError(VIR_ERR_INTERNAL_ERROR,
_("could not take snapshot of domain %s"), dom->name);
goto cleanup;
}
rc = machine->vtbl->GetCurrentSnapshot(machine, &snapshot);
if (NS_FAILED(rc)) {
- vboxError(dom->conn, VIR_ERR_INTERNAL_ERROR,
+ vboxError(VIR_ERR_INTERNAL_ERROR,
_("could not get current snapshot of domain %s"),
dom->name);
goto cleanup;
vboxIIDFromUUID(dom->uuid, domiid);
rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, domiid, &machine);
if (NS_FAILED(rc)) {
- vboxError(dom->conn, VIR_ERR_INVALID_DOMAIN, "%s",
+ vboxError(VIR_ERR_INVALID_DOMAIN, "%s",
_("no domain with matching UUID"));
goto cleanup;
}
rc = snap->vtbl->GetDescription(snap, &str16);
if (NS_FAILED(rc)) {
- vboxError(dom->conn, VIR_ERR_INTERNAL_ERROR,
+ vboxError(VIR_ERR_INTERNAL_ERROR,
_("could not get description of snapshot %s"),
snapshot->name);
goto cleanup;
rc = snap->vtbl->GetTimeStamp(snap, ×tamp);
if (NS_FAILED(rc)) {
- vboxError(dom->conn, VIR_ERR_INTERNAL_ERROR,
+ vboxError(VIR_ERR_INTERNAL_ERROR,
_("could not get creation time of snapshot %s"),
snapshot->name);
goto cleanup;
rc = snap->vtbl->GetParent(snap, &parent);
if (NS_FAILED(rc)) {
- vboxError(dom->conn, VIR_ERR_INTERNAL_ERROR,
+ vboxError(VIR_ERR_INTERNAL_ERROR,
_("could not get parent of snapshot %s"),
snapshot->name);
goto cleanup;
if (parent) {
rc = parent->vtbl->GetName(parent, &str16);
if (NS_FAILED(rc) || !str16) {
- vboxError(dom->conn, VIR_ERR_INTERNAL_ERROR,
+ vboxError(VIR_ERR_INTERNAL_ERROR,
_("could not get name of parent of snapshot %s"),
snapshot->name);
goto cleanup;
rc = snap->vtbl->GetOnline(snap, &online);
if (NS_FAILED(rc)) {
- vboxError(dom->conn, VIR_ERR_INTERNAL_ERROR,
+ vboxError(VIR_ERR_INTERNAL_ERROR,
_("could not get online state of snapshot %s"),
snapshot->name);
goto cleanup;
vboxIIDFromUUID(dom->uuid, iid);
rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid, &machine);
if (NS_FAILED(rc)) {
- vboxError(dom->conn, VIR_ERR_INVALID_DOMAIN, "%s",
+ vboxError(VIR_ERR_INVALID_DOMAIN, "%s",
_("no domain with matching UUID"));
goto cleanup;
}
rc = machine->vtbl->GetSnapshotCount(machine, &snapshotCount);
if (NS_FAILED(rc)) {
- vboxError(dom->conn, VIR_ERR_INTERNAL_ERROR,
+ vboxError(VIR_ERR_INTERNAL_ERROR,
_("could not get snapshot count for domain %s"),
dom->name);
goto cleanup;
vboxIIDFromUUID(dom->uuid, iid);
rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid, &machine);
if (NS_FAILED(rc)) {
- vboxError(dom->conn, VIR_ERR_INVALID_DOMAIN, "%s",
+ vboxError(VIR_ERR_INVALID_DOMAIN, "%s",
_("no domain with matching UUID"));
goto cleanup;
}
rc = snapshots[i]->vtbl->GetName(snapshots[i], &nameUtf16);
if (NS_FAILED(rc) || !nameUtf16) {
- vboxError(dom->conn, VIR_ERR_INTERNAL_ERROR,
+ vboxError(VIR_ERR_INTERNAL_ERROR,
"%s", _("could not get snapshot name"));
goto cleanup;
}
vboxIIDFromUUID(dom->uuid, iid);
rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid, &machine);
if (NS_FAILED(rc)) {
- vboxError(dom->conn, VIR_ERR_INVALID_DOMAIN, "%s",
+ vboxError(VIR_ERR_INVALID_DOMAIN, "%s",
_("no domain with matching UUID"));
goto cleanup;
}
vboxIIDFromUUID(dom->uuid, iid);
rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid, &machine);
if (NS_FAILED(rc) || !machine) {
- vboxError(dom->conn, VIR_ERR_INVALID_DOMAIN, "%s",
+ vboxError(VIR_ERR_INVALID_DOMAIN, "%s",
_("no domain with matching UUID"));
goto cleanup;
}
rc = machine->vtbl->GetCurrentSnapshot(machine, &snapshot);
if (NS_FAILED(rc)) {
- vboxError(dom->conn, VIR_ERR_INTERNAL_ERROR, "%s",
+ vboxError(VIR_ERR_INTERNAL_ERROR, "%s",
_("could not get current snapshot"));
goto cleanup;
}
vboxIIDFromUUID(dom->uuid, iid);
rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid, &machine);
if (NS_FAILED(rc) || !machine) {
- vboxError(dom->conn, VIR_ERR_INVALID_DOMAIN, "%s",
+ vboxError(VIR_ERR_INVALID_DOMAIN, "%s",
_("no domain with matching UUID"));
goto cleanup;
}
rc = machine->vtbl->GetCurrentSnapshot(machine, &snapshot);
if (NS_FAILED(rc)) {
- vboxError(dom->conn, VIR_ERR_INTERNAL_ERROR, "%s",
+ vboxError(VIR_ERR_INTERNAL_ERROR, "%s",
_("could not get current snapshot"));
goto cleanup;
}
if (!snapshot) {
- vboxError(dom->conn, VIR_ERR_OPERATION_INVALID, "%s",
+ vboxError(VIR_ERR_OPERATION_INVALID, "%s",
_("domain has no snapshots"));
goto cleanup;
}
rc = snapshot->vtbl->GetName(snapshot, &nameUtf16);
if (NS_FAILED(rc) || !nameUtf16) {
- vboxError(dom->conn, VIR_ERR_INTERNAL_ERROR, "%s",
+ vboxError(VIR_ERR_INTERNAL_ERROR, "%s",
_("could not get current snapshot name"));
goto cleanup;
}
rc = snapshot->vtbl->GetId(snapshot, &iid);
if (NS_FAILED(rc) || !iid) {
- vboxError(dom->conn, VIR_ERR_INTERNAL_ERROR, "%s",
+ vboxError(VIR_ERR_INTERNAL_ERROR, "%s",
_("could not get snapshot UUID"));
goto cleanup;
}
rc = machine->vtbl->SetCurrentSnapshot(machine, iid);
if (NS_FAILED(rc)) {
- vboxError(dom->conn, VIR_ERR_INTERNAL_ERROR,
+ vboxError(VIR_ERR_INTERNAL_ERROR,
_("could not restore snapshot for domain %s"), dom->name);
goto cleanup;
}
rc = machine->vtbl->GetId(machine, &domiid);
if (NS_FAILED(rc) || !domiid) {
- vboxError(dom->conn, VIR_ERR_INTERNAL_ERROR, "%s",
+ vboxError(VIR_ERR_INTERNAL_ERROR, "%s",
_("could not get domain UUID"));
goto cleanup;
}
rc = machine->vtbl->GetState(machine, &state);
if (NS_FAILED(rc)) {
- vboxError(dom->conn, VIR_ERR_INTERNAL_ERROR, "%s",
+ vboxError(VIR_ERR_INTERNAL_ERROR, "%s",
_("could not get domain state"));
goto cleanup;
}
if (state >= MachineState_FirstOnline
&& state <= MachineState_LastOnline) {
- vboxError(dom->conn, VIR_ERR_OPERATION_INVALID,
+ vboxError(VIR_ERR_OPERATION_INVALID,
_("domain %s is already running"), dom->name);
goto cleanup;
}
if (NS_SUCCEEDED(rc))
rc = data->vboxSession->vtbl->GetConsole(data->vboxSession, &console);
if (NS_FAILED(rc)) {
- vboxError(dom->conn, VIR_ERR_INTERNAL_ERROR,
+ vboxError(VIR_ERR_INTERNAL_ERROR,
_("could not open VirtualBox session with domain %s"),
dom->name);
goto cleanup;
rc = console->vtbl->RestoreSnapshot(console, snapshot, &progress);
if (NS_FAILED(rc) || !progress) {
if (rc == VBOX_E_INVALID_VM_STATE) {
- vboxError(dom->conn, VIR_ERR_OPERATION_INVALID, "%s",
+ vboxError(VIR_ERR_OPERATION_INVALID, "%s",
_("cannot restore domain snapshot for running domain"));
} else {
- vboxError(dom->conn, VIR_ERR_INTERNAL_ERROR,
+ vboxError(VIR_ERR_INTERNAL_ERROR,
_("could not restore snapshot for domain %s"),
dom->name);
}
progress->vtbl->WaitForCompletion(progress, -1);
progress->vtbl->GetResultCode(progress, &result);
if (NS_FAILED(result)) {
- vboxError(dom->conn, VIR_ERR_INTERNAL_ERROR,
+ vboxError(VIR_ERR_INTERNAL_ERROR,
_("could not restore snapshot for domain %s"), dom->name);
goto cleanup;
}
vboxIIDFromUUID(dom->uuid, domiid);
rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, domiid, &machine);
if (NS_FAILED(rc)) {
- vboxError(dom->conn, VIR_ERR_INVALID_DOMAIN, "%s",
+ vboxError(VIR_ERR_INVALID_DOMAIN, "%s",
_("no domain with matching UUID"));
goto cleanup;
}
rc = newSnapshot->vtbl->GetOnline(newSnapshot, &online);
if (NS_FAILED(rc)) {
- vboxError(dom->conn, VIR_ERR_INTERNAL_ERROR,
+ vboxError(VIR_ERR_INTERNAL_ERROR,
_("could not get online state of snapshot %s"),
snapshot->name);
goto cleanup;
rc = machine->vtbl->GetCurrentSnapshot(machine, &prevSnapshot);
if (NS_FAILED(rc)) {
- vboxError(dom->conn, VIR_ERR_INTERNAL_ERROR,
+ vboxError(VIR_ERR_INTERNAL_ERROR,
_("could not get current snapshot of domain %s"),
dom->name);
goto cleanup;
rc = machine->vtbl->GetState(machine, &state);
if (NS_FAILED(rc)) {
- vboxError(dom->conn, VIR_ERR_INTERNAL_ERROR, "%s",
+ vboxError(VIR_ERR_INTERNAL_ERROR, "%s",
_("could not get domain state"));
goto cleanup;
}
if (state >= MachineState_FirstOnline
&& state <= MachineState_LastOnline) {
- vboxError(dom->conn, VIR_ERR_OPERATION_INVALID, "%s",
+ vboxError(VIR_ERR_OPERATION_INVALID, "%s",
_("cannot revert snapshot of running domain"));
goto cleanup;
}
rc = snapshot->vtbl->GetId(snapshot, &iid);
if (NS_FAILED(rc) || !iid) {
- vboxError(NULL, VIR_ERR_INTERNAL_ERROR, "%s",
+ vboxError(VIR_ERR_INTERNAL_ERROR, "%s",
_("could not get snapshot UUID"));
goto cleanup;
}
#endif
if (NS_FAILED(rc) || !progress) {
if (rc == VBOX_E_INVALID_VM_STATE) {
- vboxError(NULL, VIR_ERR_OPERATION_INVALID, "%s",
+ vboxError(VIR_ERR_OPERATION_INVALID, "%s",
_("cannot delete domain snapshot for running domain"));
} else {
- vboxError(NULL, VIR_ERR_INTERNAL_ERROR, "%s",
+ vboxError(VIR_ERR_INTERNAL_ERROR, "%s",
_("could not delete snapshot"));
}
goto cleanup;
progress->vtbl->WaitForCompletion(progress, -1);
progress->vtbl->GetResultCode(progress, &result);
if (NS_FAILED(result)) {
- vboxError(NULL, VIR_ERR_INTERNAL_ERROR, "%s",
+ vboxError(VIR_ERR_INTERNAL_ERROR, "%s",
_("could not delete snapshot"));
goto cleanup;
}
rc = snapshot->vtbl->GetChildren(snapshot, &childrenCount, &children);
if (NS_FAILED(rc)) {
- vboxError(NULL, VIR_ERR_INTERNAL_ERROR, "%s",
+ vboxError(VIR_ERR_INTERNAL_ERROR, "%s",
_("could not get children snapshots"));
goto cleanup;
}
rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, domiid, &machine);
if (NS_FAILED(rc)) {
- vboxError(dom->conn, VIR_ERR_INVALID_DOMAIN, "%s",
+ vboxError(VIR_ERR_INVALID_DOMAIN, "%s",
_("no domain with matching UUID"));
goto cleanup;
}
rc = machine->vtbl->GetState(machine, &state);
if (NS_FAILED(rc)) {
- vboxError(dom->conn, VIR_ERR_INTERNAL_ERROR, "%s",
+ vboxError(VIR_ERR_INTERNAL_ERROR, "%s",
_("could not get domain state"));
goto cleanup;
}
if (state >= MachineState_FirstOnline
&& state <= MachineState_LastOnline) {
- vboxError(dom->conn, VIR_ERR_OPERATION_INVALID, "%s",
+ vboxError(VIR_ERR_OPERATION_INVALID, "%s",
_("cannot delete snapshots of running domain"));
goto cleanup;
}
if (NS_SUCCEEDED(rc))
rc = data->vboxSession->vtbl->GetConsole(data->vboxSession, &console);
if (NS_FAILED(rc)) {
- vboxError(dom->conn, VIR_ERR_INTERNAL_ERROR,
+ vboxError(VIR_ERR_INTERNAL_ERROR,
_("could not open VirtualBox session with domain %s"),
dom->name);
goto cleanup;
DEBUG("nnames[%d]: %s", ret, nameUtf8);
names[ret] = strdup(nameUtf8);
if (names[ret] == NULL) {
- vboxError(conn, VIR_ERR_SYSTEM_ERROR, "%s", "strdup failed");
+ virReportOOMError();
} else {
ret++;
}
DEBUG("nnames[%d]: %s", ret, nameUtf8);
names[ret] = strdup(nameUtf8);
if (names[ret] == NULL) {
- vboxError(conn, VIR_ERR_SYSTEM_ERROR, "%s", "strdup failed");
+ virReportOOMError();
} else {
ret++;
}
if (def->hosts[0].name == NULL) {
VIR_FREE(def->hosts);
def->nhosts = 0;
- vboxError(network->conn,
- VIR_ERR_SYSTEM_ERROR,
- "%s", "strdup failed");
+ virReportOOMError();
} else {
PRUnichar *macAddressUtf16 = NULL;
PRUnichar *ipAddressUtf16 = NULL;
vboxIIDUnalloc(vboxnet0IID);
VBOX_UTF16_FREE(networkNameUtf16);
} else {
- vboxError(network->conn, VIR_ERR_SYSTEM_ERROR,
- "%s", "strdup failed");
+ virReportOOMError();
}
}
hardDiskCount = 0;
} else {
hardDiskCount = -1;
- vboxError(pool->conn, VIR_ERR_INTERNAL_ERROR,"%s:%s, rc=%08x",
+ vboxError(VIR_ERR_INTERNAL_ERROR, "%s:%s, rc=%08x",
"could not get number of volumes in the pool",
pool->name, (unsigned)rc);
}
hardDiskCount = 0;
} else {
hardDiskCount = -1;
- vboxError(pool->conn, VIR_ERR_INTERNAL_ERROR,"%s:%s, rc=%08x",
+ vboxError(VIR_ERR_INTERNAL_ERROR, "%s:%s, rc=%08x",
"could not get the volume list in the pool",
pool->name, (unsigned)rc);
}