mirror of https://gitee.com/openkylin/libvirt.git
Adapt to VIR_STRDUP and VIR_STRNDUP in src/xenxs/*
This commit is contained in:
parent
63ee3b664d
commit
a551e9e1fc
|
@ -192,9 +192,8 @@ xenParseSxprChar(const char *value,
|
||||||
|
|
||||||
if (value[0] == '/') {
|
if (value[0] == '/') {
|
||||||
def->source.type = VIR_DOMAIN_CHR_TYPE_DEV;
|
def->source.type = VIR_DOMAIN_CHR_TYPE_DEV;
|
||||||
def->source.data.file.path = strdup(value);
|
if (VIR_STRDUP(def->source.data.file.path, value) < 0)
|
||||||
if (!def->source.data.file.path)
|
goto error;
|
||||||
goto no_memory;
|
|
||||||
} else {
|
} else {
|
||||||
if ((tmp = strchr(value, ':')) != NULL) {
|
if ((tmp = strchr(value, ':')) != NULL) {
|
||||||
*tmp = '\0';
|
*tmp = '\0';
|
||||||
|
@ -215,15 +214,14 @@ xenParseSxprChar(const char *value,
|
||||||
|
|
||||||
switch (def->source.type) {
|
switch (def->source.type) {
|
||||||
case VIR_DOMAIN_CHR_TYPE_PTY:
|
case VIR_DOMAIN_CHR_TYPE_PTY:
|
||||||
if (tty != NULL &&
|
if (VIR_STRDUP(def->source.data.file.path, tty) < 0)
|
||||||
!(def->source.data.file.path = strdup(tty)))
|
goto error;
|
||||||
goto no_memory;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VIR_DOMAIN_CHR_TYPE_FILE:
|
case VIR_DOMAIN_CHR_TYPE_FILE:
|
||||||
case VIR_DOMAIN_CHR_TYPE_PIPE:
|
case VIR_DOMAIN_CHR_TYPE_PIPE:
|
||||||
if (!(def->source.data.file.path = strdup(value)))
|
if (VIR_STRDUP(def->source.data.file.path, value) < 0)
|
||||||
goto no_memory;
|
goto error;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VIR_DOMAIN_CHR_TYPE_TCP:
|
case VIR_DOMAIN_CHR_TYPE_TCP:
|
||||||
|
@ -238,18 +236,14 @@ xenParseSxprChar(const char *value,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (offset != value &&
|
if (offset != value &&
|
||||||
(def->source.data.tcp.host = strndup(value,
|
VIR_STRNDUP(def->source.data.tcp.host, value, offset - value) < 0)
|
||||||
offset - value)) == NULL)
|
goto error;
|
||||||
goto no_memory;
|
|
||||||
|
|
||||||
offset2 = strchr(offset, ',');
|
offset2 = strchr(offset, ',');
|
||||||
if (offset2 == NULL)
|
offset++;
|
||||||
def->source.data.tcp.service = strdup(offset+1);
|
if (VIR_STRNDUP(def->source.data.tcp.service, offset,
|
||||||
else
|
offset2 ? offset2 - offset : strlen(offset)) < 0)
|
||||||
def->source.data.tcp.service = strndup(offset+1,
|
goto error;
|
||||||
offset2-(offset+1));
|
|
||||||
if (def->source.data.tcp.service == NULL)
|
|
||||||
goto no_memory;
|
|
||||||
|
|
||||||
if (offset2 && strstr(offset2, ",server"))
|
if (offset2 && strstr(offset2, ",server"))
|
||||||
def->source.data.tcp.listen = true;
|
def->source.data.tcp.listen = true;
|
||||||
|
@ -268,15 +262,14 @@ xenParseSxprChar(const char *value,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (offset != value &&
|
if (offset != value &&
|
||||||
(def->source.data.udp.connectHost
|
VIR_STRNDUP(def->source.data.udp.connectHost, value, offset - value) < 0)
|
||||||
= strndup(value, offset - value)) == NULL)
|
goto error;
|
||||||
goto no_memory;
|
|
||||||
|
|
||||||
offset2 = strchr(offset, '@');
|
offset2 = strchr(offset, '@');
|
||||||
if (offset2 != NULL) {
|
if (offset2 != NULL) {
|
||||||
if ((def->source.data.udp.connectService
|
if (VIR_STRNDUP(def->source.data.udp.connectService,
|
||||||
= strndup(offset + 1, offset2-(offset+1))) == NULL)
|
offset + 1, offset2 - offset - 1) < 0)
|
||||||
goto no_memory;
|
goto error;
|
||||||
|
|
||||||
offset3 = strchr(offset2, ':');
|
offset3 = strchr(offset2, ':');
|
||||||
if (offset3 == NULL) {
|
if (offset3 == NULL) {
|
||||||
|
@ -286,17 +279,15 @@ xenParseSxprChar(const char *value,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (offset3 > (offset2 + 1) &&
|
if (offset3 > (offset2 + 1) &&
|
||||||
(def->source.data.udp.bindHost
|
VIR_STRNDUP(def->source.data.udp.bindHost,
|
||||||
= strndup(offset2 + 1, offset3 - (offset2+1))) == NULL)
|
offset2 + 1, offset3 - offset2 - 1) < 0)
|
||||||
goto no_memory;
|
goto error;
|
||||||
|
|
||||||
if ((def->source.data.udp.bindService
|
if (VIR_STRDUP(def->source.data.udp.bindService, offset3 + 1) < 0)
|
||||||
= strdup(offset3 + 1)) == NULL)
|
goto error;
|
||||||
goto no_memory;
|
|
||||||
} else {
|
} else {
|
||||||
if ((def->source.data.udp.connectService
|
if (VIR_STRDUP(def->source.data.udp.connectService, offset + 1) < 0)
|
||||||
= strdup(offset + 1)) == NULL)
|
goto error;
|
||||||
goto no_memory;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -304,12 +295,9 @@ xenParseSxprChar(const char *value,
|
||||||
case VIR_DOMAIN_CHR_TYPE_UNIX:
|
case VIR_DOMAIN_CHR_TYPE_UNIX:
|
||||||
{
|
{
|
||||||
const char *offset = strchr(value, ',');
|
const char *offset = strchr(value, ',');
|
||||||
if (offset)
|
if (VIR_STRNDUP(def->source.data.nix.path, value,
|
||||||
def->source.data.nix.path = strndup(value, (offset - value));
|
offset ? offset - value : strlen(value)) < 0)
|
||||||
else
|
goto error;
|
||||||
def->source.data.nix.path = strdup(value);
|
|
||||||
if (def->source.data.nix.path == NULL)
|
|
||||||
goto no_memory;
|
|
||||||
|
|
||||||
if (offset != NULL &&
|
if (offset != NULL &&
|
||||||
strstr(offset, ",server") != NULL)
|
strstr(offset, ",server") != NULL)
|
||||||
|
@ -320,8 +308,6 @@ xenParseSxprChar(const char *value,
|
||||||
|
|
||||||
return def;
|
return def;
|
||||||
|
|
||||||
no_memory:
|
|
||||||
virReportOOMError();
|
|
||||||
error:
|
error:
|
||||||
virDomainChrDefFree(def);
|
virDomainChrDefFree(def);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -411,8 +397,8 @@ xenParseSxprDisks(virDomainDefPtr def,
|
||||||
|
|
||||||
if (sexpr_lookup(node, "device/tap2") &&
|
if (sexpr_lookup(node, "device/tap2") &&
|
||||||
STRPREFIX(src, "tap:")) {
|
STRPREFIX(src, "tap:")) {
|
||||||
if (!(disk->driverName = strdup("tap2")))
|
if (VIR_STRDUP(disk->driverName, "tap2") < 0)
|
||||||
goto no_memory;
|
goto error;
|
||||||
} else {
|
} else {
|
||||||
if (VIR_ALLOC_N(disk->driverName, (offset-src)+1) < 0)
|
if (VIR_ALLOC_N(disk->driverName, (offset-src)+1) < 0)
|
||||||
goto no_memory;
|
goto no_memory;
|
||||||
|
@ -438,8 +424,8 @@ xenParseSxprDisks(virDomainDefPtr def,
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(driverType = strndup(src, offset - src)))
|
if (VIR_STRNDUP(driverType, src, offset - src) < 0)
|
||||||
goto no_memory;
|
goto error;
|
||||||
if (STREQ(driverType, "aio"))
|
if (STREQ(driverType, "aio"))
|
||||||
disk->format = VIR_STORAGE_FILE_RAW;
|
disk->format = VIR_STORAGE_FILE_RAW;
|
||||||
else
|
else
|
||||||
|
@ -490,11 +476,10 @@ xenParseSxprDisks(virDomainDefPtr def,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(disk->dst = strdup(dst)))
|
if (VIR_STRDUP(disk->dst, dst) < 0)
|
||||||
goto no_memory;
|
goto error;
|
||||||
if (src &&
|
if (VIR_STRDUP(disk->src, src) < 0)
|
||||||
!(disk->src = strdup(src)))
|
goto error;
|
||||||
goto no_memory;
|
|
||||||
|
|
||||||
if (STRPREFIX(disk->dst, "xvd"))
|
if (STRPREFIX(disk->dst, "xvd"))
|
||||||
disk->bus = VIR_DOMAIN_DISK_BUS_XEN;
|
disk->bus = VIR_DOMAIN_DISK_BUS_XEN;
|
||||||
|
@ -572,26 +557,21 @@ xenParseSxprNets(virDomainDefPtr def,
|
||||||
net->type = VIR_DOMAIN_NET_TYPE_BRIDGE;
|
net->type = VIR_DOMAIN_NET_TYPE_BRIDGE;
|
||||||
/* XXX virtual network reverse resolve */
|
/* XXX virtual network reverse resolve */
|
||||||
|
|
||||||
if (tmp &&
|
if (VIR_STRDUP(net->data.bridge.brname, tmp) < 0)
|
||||||
!(net->data.bridge.brname = strdup(tmp)))
|
goto cleanup;
|
||||||
goto no_memory;
|
if (net->type == VIR_DOMAIN_NET_TYPE_BRIDGE &&
|
||||||
if (tmp2 &&
|
VIR_STRDUP(net->script, tmp2) < 0)
|
||||||
net->type == VIR_DOMAIN_NET_TYPE_BRIDGE &&
|
goto cleanup;
|
||||||
!(net->script = strdup(tmp2)))
|
|
||||||
goto no_memory;
|
|
||||||
tmp = sexpr_node(node, "device/vif/ip");
|
tmp = sexpr_node(node, "device/vif/ip");
|
||||||
if (tmp &&
|
if (VIR_STRDUP(net->data.bridge.ipaddr, tmp) < 0)
|
||||||
!(net->data.bridge.ipaddr = strdup(tmp)))
|
goto cleanup;
|
||||||
goto no_memory;
|
|
||||||
} else {
|
} else {
|
||||||
net->type = VIR_DOMAIN_NET_TYPE_ETHERNET;
|
net->type = VIR_DOMAIN_NET_TYPE_ETHERNET;
|
||||||
if (tmp2 &&
|
if (VIR_STRDUP(net->script, tmp2) < 0)
|
||||||
!(net->script = strdup(tmp2)))
|
goto cleanup;
|
||||||
goto no_memory;
|
|
||||||
tmp = sexpr_node(node, "device/vif/ip");
|
tmp = sexpr_node(node, "device/vif/ip");
|
||||||
if (tmp &&
|
if (VIR_STRDUP(net->data.ethernet.ipaddr, tmp) < 0)
|
||||||
!(net->data.ethernet.ipaddr = strdup(tmp)))
|
goto cleanup;
|
||||||
goto no_memory;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tmp = sexpr_node(node, "device/vif/vifname");
|
tmp = sexpr_node(node, "device/vif/vifname");
|
||||||
|
@ -599,8 +579,8 @@ xenParseSxprNets(virDomainDefPtr def,
|
||||||
* definition regardless of domain state. If vifname is not
|
* definition regardless of domain state. If vifname is not
|
||||||
* specified, only generate one if domain is active (id != -1). */
|
* specified, only generate one if domain is active (id != -1). */
|
||||||
if (tmp) {
|
if (tmp) {
|
||||||
if (!(net->ifname = strdup(tmp)))
|
if (VIR_STRDUP(net->ifname, tmp) < 0)
|
||||||
goto no_memory;
|
goto cleanup;
|
||||||
} else if (def->id != -1) {
|
} else if (def->id != -1) {
|
||||||
if (virAsprintf(&net->ifname, "vif%d.%d", def->id, vif_index) < 0)
|
if (virAsprintf(&net->ifname, "vif%d.%d", def->id, vif_index) < 0)
|
||||||
goto no_memory;
|
goto no_memory;
|
||||||
|
@ -615,14 +595,12 @@ xenParseSxprNets(virDomainDefPtr def,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (model &&
|
if (VIR_STRDUP(net->model, model) < 0)
|
||||||
!(net->model = strdup(model)))
|
goto cleanup;
|
||||||
goto no_memory;
|
|
||||||
|
|
||||||
if (!model && type &&
|
if (!model && type && STREQ(type, "netfront") &&
|
||||||
STREQ(type, "netfront") &&
|
VIR_STRDUP(net->model, "netfront") < 0)
|
||||||
!(net->model = strdup("netfront")))
|
goto cleanup;
|
||||||
goto no_memory;
|
|
||||||
|
|
||||||
if (VIR_REALLOC_N(def->nets, def->nnets + 1) < 0)
|
if (VIR_REALLOC_N(def->nets, def->nnets + 1) < 0)
|
||||||
goto no_memory;
|
goto no_memory;
|
||||||
|
@ -833,13 +811,11 @@ xenParseSxprGraphicsOld(virDomainDefPtr def,
|
||||||
virDomainGraphicsListenSetAddress(graphics, 0, listenAddr, -1, true))
|
virDomainGraphicsListenSetAddress(graphics, 0, listenAddr, -1, true))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (vncPasswd &&
|
if (VIR_STRDUP(graphics->data.vnc.auth.passwd, vncPasswd) < 0)
|
||||||
!(graphics->data.vnc.auth.passwd = strdup(vncPasswd)))
|
goto error;
|
||||||
goto no_memory;
|
|
||||||
|
|
||||||
if (keymap &&
|
if (VIR_STRDUP(graphics->data.vnc.keymap, keymap) < 0)
|
||||||
!(graphics->data.vnc.keymap = strdup(keymap)))
|
goto error;
|
||||||
goto no_memory;
|
|
||||||
|
|
||||||
if (VIR_ALLOC_N(def->graphics, 1) < 0)
|
if (VIR_ALLOC_N(def->graphics, 1) < 0)
|
||||||
goto no_memory;
|
goto no_memory;
|
||||||
|
@ -856,12 +832,10 @@ xenParseSxprGraphicsOld(virDomainDefPtr def,
|
||||||
goto no_memory;
|
goto no_memory;
|
||||||
|
|
||||||
graphics->type = VIR_DOMAIN_GRAPHICS_TYPE_SDL;
|
graphics->type = VIR_DOMAIN_GRAPHICS_TYPE_SDL;
|
||||||
if (display &&
|
if (VIR_STRDUP(graphics->data.sdl.display, display) < 0)
|
||||||
!(graphics->data.sdl.display = strdup(display)))
|
goto error;
|
||||||
goto no_memory;
|
if (VIR_STRDUP(graphics->data.sdl.xauth, xauth) < 0)
|
||||||
if (xauth &&
|
goto error;
|
||||||
!(graphics->data.sdl.xauth = strdup(xauth)))
|
|
||||||
goto no_memory;
|
|
||||||
|
|
||||||
if (VIR_ALLOC_N(def->graphics, 1) < 0)
|
if (VIR_ALLOC_N(def->graphics, 1) < 0)
|
||||||
goto no_memory;
|
goto no_memory;
|
||||||
|
@ -926,12 +900,10 @@ xenParseSxprGraphicsNew(virDomainDefPtr def,
|
||||||
if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_SDL) {
|
if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_SDL) {
|
||||||
const char *display = sexpr_node(node, "device/vfb/display");
|
const char *display = sexpr_node(node, "device/vfb/display");
|
||||||
const char *xauth = sexpr_node(node, "device/vfb/xauthority");
|
const char *xauth = sexpr_node(node, "device/vfb/xauthority");
|
||||||
if (display &&
|
if (VIR_STRDUP(graphics->data.sdl.display, display) < 0)
|
||||||
!(graphics->data.sdl.display = strdup(display)))
|
goto error;
|
||||||
goto no_memory;
|
if (VIR_STRDUP(graphics->data.sdl.xauth, xauth) < 0)
|
||||||
if (xauth &&
|
goto error;
|
||||||
!(graphics->data.sdl.xauth = strdup(xauth)))
|
|
||||||
goto no_memory;
|
|
||||||
} else {
|
} else {
|
||||||
int port;
|
int port;
|
||||||
const char *listenAddr = sexpr_node(node, "device/vfb/vnclisten");
|
const char *listenAddr = sexpr_node(node, "device/vfb/vnclisten");
|
||||||
|
@ -960,13 +932,11 @@ xenParseSxprGraphicsNew(virDomainDefPtr def,
|
||||||
virDomainGraphicsListenSetAddress(graphics, 0, listenAddr, -1, true))
|
virDomainGraphicsListenSetAddress(graphics, 0, listenAddr, -1, true))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (vncPasswd &&
|
if (VIR_STRDUP(graphics->data.vnc.auth.passwd, vncPasswd) < 0)
|
||||||
!(graphics->data.vnc.auth.passwd = strdup(vncPasswd)))
|
goto error;
|
||||||
goto no_memory;
|
|
||||||
|
|
||||||
if (keymap &&
|
if (VIR_STRDUP(graphics->data.vnc.keymap, keymap) < 0)
|
||||||
!(graphics->data.vnc.keymap = strdup(keymap)))
|
goto error;
|
||||||
goto no_memory;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_ALLOC_N(def->graphics, 1) < 0)
|
if (VIR_ALLOC_N(def->graphics, 1) < 0)
|
||||||
|
@ -1180,8 +1150,8 @@ xenParseSxpr(const struct sexpr *root,
|
||||||
|
|
||||||
if (!def->os.bootloader &&
|
if (!def->os.bootloader &&
|
||||||
sexpr_has(root, "domain/bootloader") &&
|
sexpr_has(root, "domain/bootloader") &&
|
||||||
(def->os.bootloader = strdup("")) == NULL)
|
VIR_STRDUP(def->os.bootloader, "") < 0)
|
||||||
goto no_memory;
|
goto error;
|
||||||
|
|
||||||
if (def->os.bootloader &&
|
if (def->os.bootloader &&
|
||||||
sexpr_node_copy(root, "domain/bootloader_args",
|
sexpr_node_copy(root, "domain/bootloader_args",
|
||||||
|
@ -1189,8 +1159,8 @@ xenParseSxpr(const struct sexpr *root,
|
||||||
goto no_memory;
|
goto no_memory;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(def->os.type = strdup(hvm ? "hvm" : "linux")))
|
if (VIR_STRDUP(def->os.type, hvm ? "hvm" : "linux") < 0)
|
||||||
goto no_memory;
|
goto error;
|
||||||
|
|
||||||
if (def->id != 0) {
|
if (def->id != 0) {
|
||||||
if (sexpr_lookup(root, "domain/image")) {
|
if (sexpr_lookup(root, "domain/image")) {
|
||||||
|
@ -1357,19 +1327,19 @@ xenParseSxpr(const struct sexpr *root,
|
||||||
virDomainDiskDefPtr disk;
|
virDomainDiskDefPtr disk;
|
||||||
if (VIR_ALLOC(disk) < 0)
|
if (VIR_ALLOC(disk) < 0)
|
||||||
goto no_memory;
|
goto no_memory;
|
||||||
if (!(disk->src = strdup(tmp))) {
|
if (VIR_STRDUP(disk->src, tmp) < 0) {
|
||||||
virDomainDiskDefFree(disk);
|
virDomainDiskDefFree(disk);
|
||||||
goto no_memory;
|
goto error;
|
||||||
}
|
}
|
||||||
disk->type = VIR_DOMAIN_DISK_TYPE_FILE;
|
disk->type = VIR_DOMAIN_DISK_TYPE_FILE;
|
||||||
disk->device = VIR_DOMAIN_DISK_DEVICE_CDROM;
|
disk->device = VIR_DOMAIN_DISK_DEVICE_CDROM;
|
||||||
if (!(disk->dst = strdup("hdc"))) {
|
if (VIR_STRDUP(disk->dst, "hdc") < 0) {
|
||||||
virDomainDiskDefFree(disk);
|
virDomainDiskDefFree(disk);
|
||||||
goto no_memory;
|
goto error;
|
||||||
}
|
}
|
||||||
if (!(disk->driverName = strdup("file"))) {
|
if (VIR_STRDUP(disk->driverName, "file") < 0) {
|
||||||
virDomainDiskDefFree(disk);
|
virDomainDiskDefFree(disk);
|
||||||
goto no_memory;
|
goto error;
|
||||||
}
|
}
|
||||||
disk->bus = VIR_DOMAIN_DISK_BUS_IDE;
|
disk->bus = VIR_DOMAIN_DISK_BUS_IDE;
|
||||||
disk->readonly = true;
|
disk->readonly = true;
|
||||||
|
@ -1393,19 +1363,19 @@ xenParseSxpr(const struct sexpr *root,
|
||||||
virDomainDiskDefPtr disk;
|
virDomainDiskDefPtr disk;
|
||||||
if (VIR_ALLOC(disk) < 0)
|
if (VIR_ALLOC(disk) < 0)
|
||||||
goto no_memory;
|
goto no_memory;
|
||||||
if (!(disk->src = strdup(tmp))) {
|
if (VIR_STRDUP(disk->src, tmp) < 0) {
|
||||||
VIR_FREE(disk);
|
VIR_FREE(disk);
|
||||||
goto no_memory;
|
goto error;
|
||||||
}
|
}
|
||||||
disk->type = VIR_DOMAIN_DISK_TYPE_FILE;
|
disk->type = VIR_DOMAIN_DISK_TYPE_FILE;
|
||||||
disk->device = VIR_DOMAIN_DISK_DEVICE_FLOPPY;
|
disk->device = VIR_DOMAIN_DISK_DEVICE_FLOPPY;
|
||||||
if (!(disk->dst = strdup(fds[i]))) {
|
if (VIR_STRDUP(disk->dst, fds[i]) < 0) {
|
||||||
virDomainDiskDefFree(disk);
|
virDomainDiskDefFree(disk);
|
||||||
goto no_memory;
|
goto error;
|
||||||
}
|
}
|
||||||
if (!(disk->driverName = strdup("file"))) {
|
if (VIR_STRDUP(disk->driverName, "file") < 0) {
|
||||||
virDomainDiskDefFree(disk);
|
virDomainDiskDefFree(disk);
|
||||||
goto no_memory;
|
goto error;
|
||||||
}
|
}
|
||||||
disk->bus = VIR_DOMAIN_DISK_BUS_FDC;
|
disk->bus = VIR_DOMAIN_DISK_BUS_FDC;
|
||||||
|
|
||||||
|
|
|
@ -183,12 +183,7 @@ static int xenXMConfigCopyStringInternal(virConfPtr conf,
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(*value = strdup(val->str))) {
|
return VIR_STRDUP(*value, val->str);
|
||||||
virReportOOMError();
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -288,8 +283,8 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
|
||||||
STREQ(str, "hvm"))
|
STREQ(str, "hvm"))
|
||||||
hvm = 1;
|
hvm = 1;
|
||||||
|
|
||||||
if (!(def->os.type = strdup(hvm ? "hvm" : "xen")))
|
if (VIR_STRDUP(def->os.type, hvm ? "hvm" : "xen") < 0)
|
||||||
goto no_memory;
|
goto cleanup;
|
||||||
|
|
||||||
def->os.arch =
|
def->os.arch =
|
||||||
virCapabilitiesDefaultGuestArch(caps,
|
virCapabilitiesDefaultGuestArch(caps,
|
||||||
|
@ -307,8 +302,8 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
|
||||||
def->os.arch,
|
def->os.arch,
|
||||||
virDomainVirtTypeToString(def->virtType));
|
virDomainVirtTypeToString(def->virtType));
|
||||||
if (defaultMachine != NULL) {
|
if (defaultMachine != NULL) {
|
||||||
if (!(def->os.machine = strdup(defaultMachine)))
|
if (VIR_STRDUP(def->os.machine, defaultMachine) < 0)
|
||||||
goto no_memory;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hvm) {
|
if (hvm) {
|
||||||
|
@ -562,8 +557,8 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
|
||||||
if (!(tmp = strchr(disk->src, ':')))
|
if (!(tmp = strchr(disk->src, ':')))
|
||||||
goto skipdisk;
|
goto skipdisk;
|
||||||
|
|
||||||
if (!(driverType = strndup(disk->src, tmp - disk->src)))
|
if (VIR_STRNDUP(driverType, disk->src, tmp - disk->src) < 0)
|
||||||
goto no_memory;
|
goto cleanup;
|
||||||
if (STREQ(driverType, "aio"))
|
if (STREQ(driverType, "aio"))
|
||||||
disk->format = VIR_STORAGE_FILE_RAW;
|
disk->format = VIR_STORAGE_FILE_RAW;
|
||||||
else
|
else
|
||||||
|
@ -585,8 +580,8 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
|
||||||
|
|
||||||
/* No source, or driver name, so fix to phy: */
|
/* No source, or driver name, so fix to phy: */
|
||||||
if (!disk->driverName &&
|
if (!disk->driverName &&
|
||||||
!(disk->driverName = strdup("phy")))
|
VIR_STRDUP(disk->driverName, "phy") < 0)
|
||||||
goto no_memory;
|
goto cleanup;
|
||||||
|
|
||||||
|
|
||||||
/* phy: type indicates a block device */
|
/* phy: type indicates a block device */
|
||||||
|
@ -637,12 +632,12 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
|
||||||
|
|
||||||
disk->type = VIR_DOMAIN_DISK_TYPE_FILE;
|
disk->type = VIR_DOMAIN_DISK_TYPE_FILE;
|
||||||
disk->device = VIR_DOMAIN_DISK_DEVICE_CDROM;
|
disk->device = VIR_DOMAIN_DISK_DEVICE_CDROM;
|
||||||
if (!(disk->driverName = strdup("file")))
|
if (VIR_STRDUP(disk->driverName, "file") < 0)
|
||||||
goto no_memory;
|
goto cleanup;
|
||||||
if (!(disk->src = strdup(str)))
|
if (VIR_STRDUP(disk->src, str) < 0)
|
||||||
goto no_memory;
|
goto cleanup;
|
||||||
if (!(disk->dst = strdup("hdc")))
|
if (VIR_STRDUP(disk->dst, "hdc") < 0)
|
||||||
goto no_memory;
|
goto cleanup;
|
||||||
disk->bus = VIR_DOMAIN_DISK_BUS_IDE;
|
disk->bus = VIR_DOMAIN_DISK_BUS_IDE;
|
||||||
disk->readonly = true;
|
disk->readonly = true;
|
||||||
|
|
||||||
|
@ -703,9 +698,8 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
|
||||||
} else if (STRPREFIX(key, "script=")) {
|
} else if (STRPREFIX(key, "script=")) {
|
||||||
int len = nextkey ? (nextkey - data) : strlen(data);
|
int len = nextkey ? (nextkey - data) : strlen(data);
|
||||||
VIR_FREE(script);
|
VIR_FREE(script);
|
||||||
if (!(script = strndup(data, len))) {
|
if (VIR_STRNDUP(script, data, len) < 0)
|
||||||
goto no_memory;
|
goto cleanup;
|
||||||
}
|
|
||||||
} else if (STRPREFIX(key, "model=")) {
|
} else if (STRPREFIX(key, "model=")) {
|
||||||
int len = nextkey ? (nextkey - data) : sizeof(model) - 1;
|
int len = nextkey ? (nextkey - data) : sizeof(model) - 1;
|
||||||
if (virStrncpy(model, data, len, sizeof(model)) == NULL) {
|
if (virStrncpy(model, data, len, sizeof(model)) == NULL) {
|
||||||
|
@ -763,34 +757,30 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (net->type == VIR_DOMAIN_NET_TYPE_BRIDGE) {
|
if (net->type == VIR_DOMAIN_NET_TYPE_BRIDGE) {
|
||||||
if (bridge[0] &&
|
if (bridge[0] && VIR_STRDUP(net->data.bridge.brname, bridge) < 0)
|
||||||
!(net->data.bridge.brname = strdup(bridge)))
|
goto cleanup;
|
||||||
goto no_memory;
|
if (ip[0] && VIR_STRDUP(net->data.bridge.ipaddr, ip) < 0)
|
||||||
if (ip[0] &&
|
goto cleanup;
|
||||||
!(net->data.bridge.ipaddr = strdup(ip)))
|
|
||||||
goto no_memory;
|
|
||||||
} else {
|
} else {
|
||||||
if (ip[0] &&
|
if (ip[0] && VIR_STRDUP(net->data.ethernet.ipaddr, ip) < 0)
|
||||||
!(net->data.ethernet.ipaddr = strdup(ip)))
|
goto cleanup;
|
||||||
goto no_memory;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (script && script[0] &&
|
if (script && script[0] &&
|
||||||
!(net->script = strdup(script)))
|
VIR_STRDUP(net->script, script) < 0)
|
||||||
goto no_memory;
|
goto cleanup;
|
||||||
|
|
||||||
if (model[0] &&
|
if (model[0] &&
|
||||||
!(net->model = strdup(model)))
|
VIR_STRDUP(net->model, model) < 0)
|
||||||
goto no_memory;
|
goto no_memory;
|
||||||
|
|
||||||
if (!model[0] && type[0] &&
|
if (!model[0] && type[0] && STREQ(type, "netfront") &&
|
||||||
STREQ(type, "netfront") &&
|
VIR_STRDUP(net->model, "netfront") < 0)
|
||||||
!(net->model = strdup("netfront")))
|
goto cleanup;
|
||||||
goto no_memory;
|
|
||||||
|
|
||||||
if (vifname[0] &&
|
if (vifname[0] &&
|
||||||
!(net->ifname = strdup(vifname)))
|
VIR_STRDUP(net->ifname, vifname) < 0)
|
||||||
goto no_memory;
|
goto cleanup;
|
||||||
|
|
||||||
if (VIR_REALLOC_N(def->nets, def->nnets+1) < 0)
|
if (VIR_REALLOC_N(def->nets, def->nnets+1) < 0)
|
||||||
goto no_memory;
|
goto no_memory;
|
||||||
|
@ -1019,21 +1009,21 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
|
||||||
-1, true) < 0)
|
-1, true) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
} else if (STRPREFIX(key, "vncpasswd=")) {
|
} else if (STRPREFIX(key, "vncpasswd=")) {
|
||||||
if (!(graphics->data.vnc.auth.passwd = strdup(key + 10)))
|
if (VIR_STRDUP(graphics->data.vnc.auth.passwd, key + 10) < 0)
|
||||||
goto no_memory;
|
goto cleanup;
|
||||||
} else if (STRPREFIX(key, "keymap=")) {
|
} else if (STRPREFIX(key, "keymap=")) {
|
||||||
if (!(graphics->data.vnc.keymap = strdup(key + 7)))
|
if (VIR_STRDUP(graphics->data.vnc.keymap, key + 7) < 0)
|
||||||
goto no_memory;
|
goto cleanup;
|
||||||
} else if (STRPREFIX(key, "vncdisplay=")) {
|
} else if (STRPREFIX(key, "vncdisplay=")) {
|
||||||
graphics->data.vnc.port = strtol(key+11, NULL, 10) + 5900;
|
graphics->data.vnc.port = strtol(key+11, NULL, 10) + 5900;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (STRPREFIX(key, "display=")) {
|
if (STRPREFIX(key, "display=")) {
|
||||||
if (!(graphics->data.sdl.display = strdup(key + 8)))
|
if (VIR_STRDUP(graphics->data.sdl.display, key + 8) < 0)
|
||||||
goto no_memory;
|
goto cleanup;
|
||||||
} else if (STRPREFIX(key, "xauthority=")) {
|
} else if (STRPREFIX(key, "xauthority=")) {
|
||||||
if (!(graphics->data.sdl.xauth = strdup(key + 11)))
|
if (VIR_STRDUP(graphics->data.sdl.xauth, key + 11) < 0)
|
||||||
goto no_memory;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1193,9 +1183,8 @@ int xenXMConfigSetString(virConfPtr conf, const char *setting, const char *str)
|
||||||
|
|
||||||
value->type = VIR_CONF_STRING;
|
value->type = VIR_CONF_STRING;
|
||||||
value->next = NULL;
|
value->next = NULL;
|
||||||
if (!(value->str = strdup(str))) {
|
if (VIR_STRDUP(value->str, str) < 0) {
|
||||||
VIR_FREE(value);
|
VIR_FREE(value);
|
||||||
virReportOOMError();
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue