提交 06030f05 编写于 作者: M Michal Privoznik

vz: Use g_strdup_printf() instead of virAsprintf()

Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
Reviewed-by: NDaniel Henrique Barboza <danielhb413@gmail.com>
上级 3bfb3599
...@@ -2935,8 +2935,7 @@ vzMigrationCreateURI(void) ...@@ -2935,8 +2935,7 @@ vzMigrationCreateURI(void)
goto cleanup; goto cleanup;
} }
if (virAsprintf(&uri, "vzmigr://%s", hostname) < 0) uri = g_strdup_printf("vzmigr://%s", hostname);
goto cleanup;
cleanup: cleanup:
VIR_FREE(hostname); VIR_FREE(hostname);
......
...@@ -1213,27 +1213,22 @@ prlsdkGetSerialInfo(PRL_HANDLE serialPort, virDomainChrDefPtr chr) ...@@ -1213,27 +1213,22 @@ prlsdkGetSerialInfo(PRL_HANDLE serialPort, virDomainChrDefPtr chr)
break; break;
case PDT_USE_TCP: case PDT_USE_TCP:
chr->source->type = VIR_DOMAIN_CHR_TYPE_TCP; chr->source->type = VIR_DOMAIN_CHR_TYPE_TCP;
if (virAsprintf(&uristr, "tcp://%s", friendlyName) < 0) uristr = g_strdup_printf("tcp://%s", friendlyName);
goto cleanup;
if (!(uri = virURIParse(uristr))) if (!(uri = virURIParse(uristr)))
goto cleanup; goto cleanup;
chr->source->data.tcp.host = g_strdup(uri->server); chr->source->data.tcp.host = g_strdup(uri->server);
if (virAsprintf(&chr->source->data.tcp.service, "%d", uri->port) < 0) chr->source->data.tcp.service = g_strdup_printf("%d", uri->port);
goto cleanup;
chr->source->data.tcp.listen = socket_mode == PSP_SERIAL_SOCKET_SERVER; chr->source->data.tcp.listen = socket_mode == PSP_SERIAL_SOCKET_SERVER;
break; break;
case PDT_USE_UDP: case PDT_USE_UDP:
chr->source->type = VIR_DOMAIN_CHR_TYPE_UDP; chr->source->type = VIR_DOMAIN_CHR_TYPE_UDP;
if (virAsprintf(&uristr, "udp://%s", friendlyName) < 0) uristr = g_strdup_printf("udp://%s", friendlyName);
goto cleanup;
if (!(uri = virURIParse(uristr))) if (!(uri = virURIParse(uristr)))
goto cleanup; goto cleanup;
chr->source->data.udp.bindHost = g_strdup(uri->server); chr->source->data.udp.bindHost = g_strdup(uri->server);
if (virAsprintf(&chr->source->data.udp.bindService, "%d", uri->port) < 0) chr->source->data.udp.bindService = g_strdup_printf("%d", uri->port);
goto cleanup;
chr->source->data.udp.connectHost = g_strdup(uri->server); chr->source->data.udp.connectHost = g_strdup(uri->server);
if (virAsprintf(&chr->source->data.udp.connectService, "%d", uri->port) < 0) chr->source->data.udp.connectService = g_strdup_printf("%d", uri->port);
goto cleanup;
break; break;
default: default:
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
...@@ -3128,20 +3123,16 @@ static int prlsdkAddSerial(PRL_HANDLE sdkdom, virDomainChrDefPtr chr) ...@@ -3128,20 +3123,16 @@ static int prlsdkAddSerial(PRL_HANDLE sdkdom, virDomainChrDefPtr chr)
break; break;
case VIR_DOMAIN_CHR_TYPE_TCP: case VIR_DOMAIN_CHR_TYPE_TCP:
emutype = PDT_USE_TCP; emutype = PDT_USE_TCP;
if (virAsprintf(&url, "%s:%s", url = g_strdup_printf("%s:%s", chr->source->data.tcp.host,
chr->source->data.tcp.host, chr->source->data.tcp.service);
chr->source->data.tcp.service) < 0)
goto cleanup;
if (!chr->source->data.tcp.listen) if (!chr->source->data.tcp.listen)
socket_mode = PSP_SERIAL_SOCKET_CLIENT; socket_mode = PSP_SERIAL_SOCKET_CLIENT;
path = url; path = url;
break; break;
case VIR_DOMAIN_CHR_TYPE_UDP: case VIR_DOMAIN_CHR_TYPE_UDP:
emutype = PDT_USE_UDP; emutype = PDT_USE_UDP;
if (virAsprintf(&url, "%s:%s", url = g_strdup_printf("%s:%s", chr->source->data.udp.bindHost,
chr->source->data.udp.bindHost, chr->source->data.udp.bindService);
chr->source->data.udp.bindService) < 0)
goto cleanup;
path = url; path = url;
break; break;
default: default:
...@@ -3333,10 +3324,7 @@ static int prlsdkConfigureNet(vzDriverPtr driver G_GNUC_UNUSED, ...@@ -3333,10 +3324,7 @@ static int prlsdkConfigureNet(vzDriverPtr driver G_GNUC_UNUSED,
if (!(tmpstr = virSocketAddrFormat(&net->guestIP.ips[i]->address))) if (!(tmpstr = virSocketAddrFormat(&net->guestIP.ips[i]->address)))
goto cleanup; goto cleanup;
if (virAsprintf(&addrstr, "%s/%d", tmpstr, net->guestIP.ips[i]->prefix) < 0) { addrstr = g_strdup_printf("%s/%d", tmpstr, net->guestIP.ips[i]->prefix);
VIR_FREE(tmpstr);
goto cleanup;
}
VIR_FREE(tmpstr); VIR_FREE(tmpstr);
pret = PrlStrList_AddItem(addrlist, addrstr); pret = PrlStrList_AddItem(addrlist, addrstr);
...@@ -3791,9 +3779,8 @@ prlsdkAddFS(PRL_HANDLE sdkdom, virDomainFSDefPtr fs) ...@@ -3791,9 +3779,8 @@ prlsdkAddFS(PRL_HANDLE sdkdom, virDomainFSDefPtr fs)
prlsdkCheckRetGoto(pret, cleanup); prlsdkCheckRetGoto(pret, cleanup);
if (fs->type == VIR_DOMAIN_FS_TYPE_VOLUME) { if (fs->type == VIR_DOMAIN_FS_TYPE_VOLUME) {
if (virAsprintf(&storage, "libvirt://localhost/%s/%s", fs->src->srcpool->pool, storage = g_strdup_printf("libvirt://localhost/%s/%s",
fs->src->srcpool->volume) < 0) fs->src->srcpool->pool, fs->src->srcpool->volume);
goto cleanup;
pret = PrlVmDevHd_SetStorageURL(sdkdisk, storage); pret = PrlVmDevHd_SetStorageURL(sdkdisk, storage);
prlsdkCheckRetGoto(pret, cleanup); prlsdkCheckRetGoto(pret, cleanup);
} }
...@@ -4406,8 +4393,7 @@ prlsdkGetBlockStats(PRL_HANDLE sdkstats, ...@@ -4406,8 +4393,7 @@ prlsdkGetBlockStats(PRL_HANDLE sdkstats,
#define PRLSDK_GET_STAT_PARAM(VAL, TYPE, NAME) \ #define PRLSDK_GET_STAT_PARAM(VAL, TYPE, NAME) \
if (virAsprintf(&name, "devices.%s%d.%s", prefix, idx, NAME) < 0) \ name = g_strdup_printf("devices.%s%d.%s", prefix, idx, NAME); \
goto cleanup; \
if (prlsdkExtractStatsParam(sdkstats, name, &stats->VAL) < 0) \ if (prlsdkExtractStatsParam(sdkstats, name, &stats->VAL) < 0) \
goto cleanup; \ goto cleanup; \
VIR_FREE(name); VIR_FREE(name);
...@@ -4487,8 +4473,7 @@ prlsdkGetNetStats(PRL_HANDLE sdkstats, PRL_HANDLE sdkdom, const char *device, ...@@ -4487,8 +4473,7 @@ prlsdkGetNetStats(PRL_HANDLE sdkstats, PRL_HANDLE sdkdom, const char *device,
prlsdkCheckRetGoto(pret, cleanup); prlsdkCheckRetGoto(pret, cleanup);
#define PRLSDK_GET_NET_COUNTER(VAL, NAME) \ #define PRLSDK_GET_NET_COUNTER(VAL, NAME) \
if (virAsprintf(&name, "net.nic%u.%s", net_index, NAME) < 0) \ name = g_strdup_printf("net.nic%u.%s", net_index, NAME); \
goto cleanup; \
if (prlsdkExtractStatsParam(sdkstats, name, &stats->VAL) < 0) \ if (prlsdkExtractStatsParam(sdkstats, name, &stats->VAL) < 0) \
goto cleanup; \ goto cleanup; \
VIR_FREE(name); VIR_FREE(name);
...@@ -4519,8 +4504,7 @@ prlsdkGetVcpuStats(PRL_HANDLE sdkstats, int idx, unsigned long long *vtime) ...@@ -4519,8 +4504,7 @@ prlsdkGetVcpuStats(PRL_HANDLE sdkstats, int idx, unsigned long long *vtime)
long long ptime = 0; long long ptime = 0;
int ret = -1; int ret = -1;
if (virAsprintf(&name, "guest.vcpu%u.time", (unsigned int)idx) < 0) name = g_strdup_printf("guest.vcpu%u.time", (unsigned int)idx);
goto cleanup;
if (prlsdkExtractStatsParam(sdkstats, name, &ptime) < 0) if (prlsdkExtractStatsParam(sdkstats, name, &ptime) < 0)
goto cleanup; goto cleanup;
*vtime = ptime == -1 ? 0 : ptime; *vtime = ptime == -1 ? 0 : ptime;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册