}
for (i = 0; i < line_count; i++) {
- curr = lines[i];
size_t j;
char **arglist = NULL;
size_t args_count = 0;
size_t args_alloc = 0;
+ curr = lines[i];
+
/* iterate over each line, splitting on sequences of ' '. This code is
* adapted from qemu/qemu_parse_command.c. */
while (curr && *curr != '\0') {
void virDomainSoundDefFree(virDomainSoundDefPtr def)
{
+ size_t i;
+
if (!def)
return;
virDomainDeviceInfoClear(&def->info);
- size_t i;
for (i = 0; i < def->ncodecs; i++)
virDomainSoundCodecDefFree(def->codecs[i]);
VIR_FREE(def->codecs);
static void
virDomainClockDefClear(virDomainClockDefPtr def)
{
+ size_t i;
+
if (def->offset == VIR_DOMAIN_CLOCK_OFFSET_TIMEZONE)
VIR_FREE(def->data.timezone);
- size_t i;
for (i = 0; i < def->ntimers; i++)
VIR_FREE(def->timers[i]);
VIR_FREE(def->timers);
virDomainMemoryDefPtr def)
{
VIR_XPATH_NODE_AUTORESTORE(ctxt);
- ctxt->node = node;
g_autofree char *nodemask = NULL;
+ ctxt->node = node;
+
switch ((virDomainMemoryModel) def->model) {
case VIR_DOMAIN_MEMORY_MODEL_DIMM:
if (virDomainParseMemory("./pagesize", "./pagesize/@unit", ctxt,
if (def->forward.type != VIR_NETWORK_FORWARD_NONE) {
const char *dev = NULL;
+ const char *mode = virNetworkForwardTypeToString(def->forward.type);
+
if (!def->forward.npfs)
dev = virNetworkDefForwardIf(def, 0);
- const char *mode = virNetworkForwardTypeToString(def->forward.type);
if (!mode) {
virReportError(VIR_ERR_INTERNAL_ERROR,
/* UUID does not match, but if a name matches, refuse it */
obj = virStoragePoolObjFindByNameLocked(pools, def->name);
if (obj) {
+ char uuidstr[VIR_UUID_STRING_BUFLEN];
+
virObjectLock(obj);
- char uuidstr[VIR_UUID_STRING_BUFLEN];
virUUIDFormat(obj->def->uuid, uuidstr);
virReportError(VIR_ERR_OPERATION_FAILED,
_("pool '%s' already exists with uuid %s"),
pcap_close(handle);
if (req->status == 0) {
+ g_autofree char *inetaddr = NULL;
int ret;
virSocketAddr sa;
sa.len = sizeof(sa.data.inet4);
sa.data.inet4.sin_family = AF_INET;
sa.data.inet4.sin_addr.s_addr = vmaddr;
- g_autofree char *inetaddr = NULL;
/* It is necessary to unlock interface here to avoid updateMutex and
* interface ordering deadlocks. Otherwise we are going to
} else if (ret > 0) {
token = strtok_r(temp, ";", &saveptr);
while (token != NULL) {
+ char *p = token;
+ char cpy_temp[32];
+ int len;
+
/* add new device to list */
if (VIR_ALLOC(net) < 0)
goto error;
net->type = VIR_DOMAIN_NET_TYPE_BRIDGE;
- char *p = token;
- char cpy_temp[32];
- int len;
-
/* parse string */
do {
char *next = strchr(p, ',');
if (priv->fakeReboot) {
g_autofree char *name = g_strdup_printf("reboot-%s", vm->def->name);
+ virThread th;
+
qemuDomainSetFakeReboot(driver, vm, false);
virObjectRef(vm);
- virThread th;
if (virThreadCreateFull(&th,
false,
qemuProcessFakeReboot,
bool tty = true;
#endif
int mode;
+ size_t i;
if (inside_daemon && !conn->uri->server) {
mode = REMOTE_DRIVER_MODE_DIRECT;
* feasibly it might contain variables needed by the real driver,
* although that won't be the case for now).
*/
- size_t i;
-
if (conn->uri) {
for (i = 0; i < conn->uri->paramsCount; i++) {
virURIParamPtr var = &conn->uri->params[i];
* blocks */
amtleft = amtread;
do {
- interval = ((wbytes > amtleft) ? amtleft : wbytes);
int offset = amtread - amtleft;
+ interval = ((wbytes > amtleft) ? amtleft : wbytes);
if (want_sparse && memcmp(buf+offset, zerobuf, interval) == 0) {
if (lseek(fd, interval, SEEK_CUR) < 0) {
case DBUS_TYPE_SIGNATURE:
do {
char **x;
+ char *s;
if (arrayref) {
char ***xptrptr = arrayptr;
if (VIR_EXPAND_N(*xptrptr, *narrayptr, 1) < 0)
} else {
x = (char **)va_arg(args, char **);
}
- char *s;
dbus_message_iter_get_basic(iter, &s);
*x = g_strdup(s);
VIR_DEBUG("Read basic type 'char *' varg 'char **'"
size_t i;
for (i = 0; i < virJSONValueArraySize(array); i++) {
- member = virJSONValueArrayGet((virJSONValuePtr) array, i);
g_autofree char *prefix = NULL;
+ member = virJSONValueArrayGet((virJSONValuePtr) array, i);
prefix = g_strdup_printf("%s.%zu", key, i);
if (virQEMUBuildCommandLineJSONRecurse(prefix, member, buf, skipKey, onOff,
vboxConnectGetMaxVcpus(virConnectPtr conn, const char *type G_GNUC_UNUSED)
{
vboxDriverPtr data = conn->privateData;
+ ISystemProperties *systemProperties = NULL;
PRUint32 maxCPUCount = 0;
int ret = -1;
/* VirtualBox Supports only hvm and thus the type passed to it
* has no meaning, setting it to G_GNUC_UNUSED
*/
- ISystemProperties *systemProperties = NULL;
gVBoxAPI.UIVirtualBox.GetSystemProperties(data->vboxObj, &systemProperties);
if (!systemProperties)
char *nameTmpUse = NULL;
bool snapshotFileExists = false;
bool needToChangeStorageController = false;
+ char uuidtmp[VIR_UUID_STRING_BUFLEN];
int ret = -1;
if (!data->vboxObj)
char *parentUuid = NULL;
virVBoxSnapshotConfHardDiskPtr readOnlyDisk = NULL;
vboxIID iid, parentiid;
+ IMedium *parentReadOnlyMedium = NULL;
VBOX_IID_INITIALIZE(&iid);
VBOX_IID_INITIALIZE(&parentiid);
VBOX_UTF16_FREE(formatUtf);
/* This disk is already in the media registry */
- IMedium *parentReadOnlyMedium = NULL;
rc = gVBoxAPI.UIMedium.GetParent(readOnlyMedium, &parentReadOnlyMedium);
if (NS_FAILED(rc)) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
if (virUUIDGenerate(snapshotUuid) < 0)
goto cleanup;
- char uuidtmp[VIR_UUID_STRING_BUFLEN];
virUUIDFormat(snapshotUuid, uuidtmp);
newSnapshotPtr->uuid = g_strdup(uuidtmp);
}
}
} else {
+ char *snapshotContent;
/* Create a "fake" disk to avoid corrupting children snapshot disks. */
for (it = 0; it < def->parent.dom->ndisks; it++) {
IMedium *medium = NULL;
char *format = NULL;
char *tmp = NULL;
vboxIID iid, parentiid;
+ IProgress *progress = NULL;
+ PRUint32 tab[1];
VBOX_IID_INITIALIZE(&iid);
VBOX_IID_INITIALIZE(&parentiid);
goto cleanup;
}
- IProgress *progress = NULL;
- PRUint32 tab[1];
tab[0] = MediumVariant_Diff;
gVBoxAPI.UIMedium.CreateDiffStorage(medium, newMedium, 1, tab, &progress);
VIR_FREE(currentSnapshotXmlFilePath);
currentSnapshotXmlFilePath = g_strdup_printf("%s%s.xml",
machineLocationPath, snapshotMachineDesc->currentSnapshot);
- char *snapshotContent = virDomainSnapshotDefFormat(NULL, def,
- data->xmlopt,
- VIR_DOMAIN_SNAPSHOT_FORMAT_SECURE);
+ snapshotContent = virDomainSnapshotDefFormat(NULL, def,
+ data->xmlopt,
+ VIR_DOMAIN_SNAPSHOT_FORMAT_SECURE);
if (snapshotContent == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Unable to get snapshot content"));
char *tmp = NULL;
vboxIID iid, parentiid;
resultCodeUnion resultCode;
+ PRUint32 tab[1];
VBOX_IID_INITIALIZE(&iid);
VBOX_IID_INITIALIZE(&parentiid);
VBOX_UTF16_FREE(formatUtf16);
VBOX_UTF16_FREE(newLocation);
- PRUint32 tab[1];
tab[0] = MediumVariant_Diff;
gVBoxAPI.UIMedium.CreateDiffStorage(medium, newMedium, 1, tab, &progress);
for (i = 0; i < machines.count; i++) {
IMachine *machine = machines.items[i];
+ PRBool isAccessible = PR_FALSE;
int id = -1;
if (!machine)
continue;
- PRBool isAccessible = PR_FALSE;
gVBoxAPI.UIMachine.GetAccessible(machine, &isAccessible);
if (!isAccessible)
for (i = 0; i < nodeSize; i++) {
xmlNodePtr node = nodes[i];
+ xmlNodePtr sourceNode;
+
xPathContext->node = node;
- xmlNodePtr sourceNode = virXPathNode("./source", xPathContext);
+ sourceNode = virXPathNode("./source", xPathContext);
if (sourceNode)
ret[i] = virXMLPropString(sourceNode, "file");
}
for (i = 0; i < nodeSize; i++) {
xmlNodePtr node = nodes[i];
+ xmlNodePtr sourceNode;
+
xPathContext->node = node;
- xmlNodePtr sourceNode = virXPathNode("./source", xPathContext);
+ sourceNode = virXPathNode("./source", xPathContext);
if (sourceNode)
ret[i] = virXMLPropString(sourceNode, "file");
}
};
size_t i, j, k;
+ G_STATIC_ASSERT(G_N_ELEMENTS(archs) == G_N_ELEMENTS(emulators));
+
if ((caps = virCapabilitiesNew(virArchFromHost(),
false, false)) == NULL)
return NULL;
if (virCapabilitiesInitCaches(caps) < 0)
goto error;
- G_STATIC_ASSERT(G_N_ELEMENTS(archs) == G_N_ELEMENTS(emulators));
-
for (i = 0; i < G_N_ELEMENTS(ostypes); i++)
for (j = 0; j < G_N_ELEMENTS(archs); j++)
for (k = 0; k < G_N_ELEMENTS(emulators); k++)
static int
vzDomainDefAddDefaultInputDevices(virDomainDefPtr def)
{
- if (def->ngraphics == 0)
- return 0;
-
int bus = IS_CT(def) ? VIR_DOMAIN_INPUT_BUS_PARALLELS :
VIR_DOMAIN_INPUT_BUS_PS2;
+ if (def->ngraphics == 0)
+ return 0;
+
if (virDomainDefMaybeAddInput(def,
VIR_DOMAIN_INPUT_TYPE_MOUSE,
bus) < 0)
char c;
bool daemonize_check = false;
size_t daemonize_retries = 3;
+ char buf[1024];
+ ssize_t got;
if (!log)
return ret;
usleep(100*1000);
}
- char buf[1024];
- ssize_t got;
-
fprintf(stdout, "BEGIN STDOUT\n");
fflush(stdout);
fprintf(stderr, "BEGIN STDERR\n");
testEventReport(const char *name, bool failed, const char *msg, ...)
{
va_list vargs;
- va_start(vargs, msg);
char *str = NULL;
struct testEventResultData data;
+ va_start(vargs, msg);
+
if (msg)
str = g_strdup_vprintf(msg, vargs);
size_t i;
pthread_t eventThread;
char one = '1';
+ char *debugEnv = getenv("LIBVIRT_DEBUG");
for (i = 0; i < NUM_FDS; i++) {
if (virPipeQuiet(handles[i].pipeFD) < 0) {
}
}
- char *debugEnv = getenv("LIBVIRT_DEBUG");
if (debugEnv && *debugEnv &&
(virLogSetDefaultPriority(virLogParseDefaultPriority(debugEnv)) < 0)) {
fprintf(stderr, "Invalid log level setting.\n");
init_syms();
if (STRPREFIX(path, SYSFS_CGROUP_PREFIX)) {
- init_sysfs();
char *newpath;
+
+ init_sysfs();
+
if (asprintf(&newpath, "%s%s",
fakesysfscgroupdir,
path + strlen(SYSFS_CGROUP_PREFIX)) < 0) {
init_syms();
if (STRPREFIX(path, SYSFS_CGROUP_PREFIX)) {
- init_sysfs();
char *newpath;
+
+ init_sysfs();
+
if (asprintf(&newpath, "%s%s",
fakesysfscgroupdir,
path + strlen(SYSFS_CGROUP_PREFIX)) < 0) {
goto error;
for (i = 0; i < nvol_nodes; i++) {
- ctxt->node = vol_nodes[i];
virshUndefineVolume vol;
+
+ ctxt->node = vol_nodes[i];
+
VIR_FREE(source);
VIR_FREE(target);
VIR_FREE(pool);
const char *n = NULL;
bool is_mac = false;
virMacAddr dummy;
- virCheckFlags(VIRSH_BYNAME | VIRSH_BYMAC, NULL);
virshControlPtr priv = ctl->privData;
+ virCheckFlags(VIRSH_BYNAME | VIRSH_BYMAC, NULL);
+
if (!optname)
optname = "interface";
virNetworkPtr network = NULL;
const char *n = NULL;
const char *optname = "network";
- virCheckFlags(VIRSH_BYUUID | VIRSH_BYNAME, NULL);
virshControlPtr priv = ctl->privData;
+ virCheckFlags(VIRSH_BYUUID | VIRSH_BYNAME, NULL);
+
if (vshCommandOptStringReq(ctl, cmd, optname, &n) < 0)
return NULL;
char **caps = NULL;
int ncaps = 0;
bool match = false;
+ size_t j, k;
device = list->devices[i];
/* Check if the device's capability matches with provided
* capabilities.
*/
- size_t j, k;
for (j = 0; j < ncaps; j++) {
for (k = 0; k < ncapnames; k++) {
if (STREQ(caps[j], capnames[k])) {
{
virDomainPtr dom = NULL;
int id;
- virCheckFlags(VIRSH_BYID | VIRSH_BYUUID | VIRSH_BYNAME, NULL);
virshControlPtr priv = ctl->privData;
+ virCheckFlags(VIRSH_BYID | VIRSH_BYUUID | VIRSH_BYNAME, NULL);
+
/* try it by ID */
if (flags & VIRSH_BYID) {
if (virStrToLong_i(name, NULL, 10, &id) == 0 && id >= 0) {
virHostValidateLevel level,
const char *hint)
{
- virHostMsgCheck(hvname, "for namespace %s", ns_name);
char nspath[100];
+ virHostMsgCheck(hvname, "for namespace %s", ns_name);
+
g_snprintf(nspath, sizeof(nspath), "/proc/self/ns/%s", ns_name);
if (access(nspath, F_OK) < 0) {