mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
Split declarations from initializations
Split those initializations that depend on a statement above them. Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
a5152f23e7
commit
0a37e0695b
@ -1935,11 +1935,13 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt,
|
|||||||
addrMatch = false;
|
addrMatch = false;
|
||||||
for (j = 0; j < nips; j++) {
|
for (j = 0; j < nips; j++) {
|
||||||
virNetworkIPDefPtr def2 = &def->ips[j];
|
virNetworkIPDefPtr def2 = &def->ips[j];
|
||||||
|
int prefix;
|
||||||
|
|
||||||
if (VIR_SOCKET_ADDR_FAMILY(gateway)
|
if (VIR_SOCKET_ADDR_FAMILY(gateway)
|
||||||
!= VIR_SOCKET_ADDR_FAMILY(&def2->address)) {
|
!= VIR_SOCKET_ADDR_FAMILY(&def2->address)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int prefix = virNetworkIPDefPrefix(def2);
|
prefix = virNetworkIPDefPrefix(def2);
|
||||||
virSocketAddrMaskByPrefix(&def2->address, prefix, &testAddr);
|
virSocketAddrMaskByPrefix(&def2->address, prefix, &testAddr);
|
||||||
virSocketAddrMaskByPrefix(gateway, prefix, &testGw);
|
virSocketAddrMaskByPrefix(gateway, prefix, &testGw);
|
||||||
if (VIR_SOCKET_ADDR_VALID(&testAddr) &&
|
if (VIR_SOCKET_ADDR_VALID(&testAddr) &&
|
||||||
|
@ -2864,10 +2864,13 @@ virNWFilterRuleDefDetailsFormat(virBufferPtr buf,
|
|||||||
nwItemDesc *item;
|
nwItemDesc *item;
|
||||||
|
|
||||||
while (att[i].name) {
|
while (att[i].name) {
|
||||||
|
virNWFilterEntryItemFlags flags;
|
||||||
|
|
||||||
VIR_WARNINGS_NO_CAST_ALIGN
|
VIR_WARNINGS_NO_CAST_ALIGN
|
||||||
item = (nwItemDesc *)((char *)def + att[i].dataIdx);
|
item = (nwItemDesc *)((char *)def + att[i].dataIdx);
|
||||||
VIR_WARNINGS_RESET
|
VIR_WARNINGS_RESET
|
||||||
virNWFilterEntryItemFlags flags = item->flags;
|
|
||||||
|
flags = item->flags;
|
||||||
if ((flags & NWFILTER_ENTRY_ITEM_FLAG_EXISTS)) {
|
if ((flags & NWFILTER_ENTRY_ITEM_FLAG_EXISTS)) {
|
||||||
if (!typeShown) {
|
if (!typeShown) {
|
||||||
virBufferAsprintf(buf, "<%s", type);
|
virBufferAsprintf(buf, "<%s", type);
|
||||||
|
@ -1490,11 +1490,12 @@ static int virLXCControllerPopulateDevices(virLXCControllerPtr ctrl)
|
|||||||
/* Populate /dev/ with a few important bits */
|
/* Populate /dev/ with a few important bits */
|
||||||
for (i = 0; i < G_N_ELEMENTS(devs); i++) {
|
for (i = 0; i < G_N_ELEMENTS(devs); i++) {
|
||||||
g_autofree char *path = NULL;
|
g_autofree char *path = NULL;
|
||||||
|
dev_t dev;
|
||||||
|
|
||||||
path = g_strdup_printf("/%s/%s.dev/%s", LXC_STATE_DIR, ctrl->def->name,
|
path = g_strdup_printf("/%s/%s.dev/%s", LXC_STATE_DIR, ctrl->def->name,
|
||||||
devs[i].path);
|
devs[i].path);
|
||||||
|
|
||||||
dev_t dev = makedev(devs[i].maj, devs[i].min);
|
dev = makedev(devs[i].maj, devs[i].min);
|
||||||
if (mknod(path, S_IFCHR, dev) < 0 ||
|
if (mknod(path, S_IFCHR, dev) < 0 ||
|
||||||
chmod(path, devs[i].mode)) {
|
chmod(path, devs[i].mode)) {
|
||||||
virReportSystemError(errno,
|
virReportSystemError(errno,
|
||||||
@ -1990,11 +1991,12 @@ static int virLXCControllerMoveInterfaces(virLXCControllerPtr ctrl)
|
|||||||
|
|
||||||
for (i = 0; i < def->nhostdevs; i ++) {
|
for (i = 0; i < def->nhostdevs; i ++) {
|
||||||
virDomainHostdevDefPtr hdev = def->hostdevs[i];
|
virDomainHostdevDefPtr hdev = def->hostdevs[i];
|
||||||
|
virDomainHostdevCaps hdcaps;
|
||||||
|
|
||||||
if (hdev->mode != VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES)
|
if (hdev->mode != VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
virDomainHostdevCaps hdcaps = hdev->source.caps;
|
hdcaps = hdev->source.caps;
|
||||||
|
|
||||||
if (hdcaps.type != VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET)
|
if (hdcaps.type != VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET)
|
||||||
continue;
|
continue;
|
||||||
|
@ -1440,6 +1440,7 @@ static virSecurityManagerPtr
|
|||||||
lxcSecurityInit(virLXCDriverConfigPtr cfg)
|
lxcSecurityInit(virLXCDriverConfigPtr cfg)
|
||||||
{
|
{
|
||||||
unsigned int flags = VIR_SECURITY_MANAGER_PRIVILEGED;
|
unsigned int flags = VIR_SECURITY_MANAGER_PRIVILEGED;
|
||||||
|
virSecurityManagerPtr mgr;
|
||||||
|
|
||||||
VIR_INFO("lxcSecurityInit %s", cfg->securityDriverName);
|
VIR_INFO("lxcSecurityInit %s", cfg->securityDriverName);
|
||||||
|
|
||||||
@ -1448,8 +1449,8 @@ lxcSecurityInit(virLXCDriverConfigPtr cfg)
|
|||||||
if (cfg->securityRequireConfined)
|
if (cfg->securityRequireConfined)
|
||||||
flags |= VIR_SECURITY_MANAGER_REQUIRE_CONFINED;
|
flags |= VIR_SECURITY_MANAGER_REQUIRE_CONFINED;
|
||||||
|
|
||||||
virSecurityManagerPtr mgr = virSecurityManagerNew(cfg->securityDriverName,
|
mgr = virSecurityManagerNew(cfg->securityDriverName,
|
||||||
LXC_DRIVER_NAME, flags);
|
LXC_DRIVER_NAME, flags);
|
||||||
if (!mgr)
|
if (!mgr)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
@ -4235,7 +4235,9 @@ qemuBuildVgaVideoCommand(virCommandPtr cmd,
|
|||||||
virDomainVideoDefPtr video,
|
virDomainVideoDefPtr video,
|
||||||
virQEMUCapsPtr qemuCaps)
|
virQEMUCapsPtr qemuCaps)
|
||||||
{
|
{
|
||||||
|
const char *dev;
|
||||||
const char *vgastr = qemuVideoTypeToString(video->type);
|
const char *vgastr = qemuVideoTypeToString(video->type);
|
||||||
|
|
||||||
if (!vgastr || STREQ(vgastr, "")) {
|
if (!vgastr || STREQ(vgastr, "")) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("invalid model for video type '%s'"),
|
_("invalid model for video type '%s'"),
|
||||||
@ -4256,7 +4258,7 @@ qemuBuildVgaVideoCommand(virCommandPtr cmd,
|
|||||||
* See 'Graphics Devices' section in docs/qdev-device-use.txt in
|
* See 'Graphics Devices' section in docs/qdev-device-use.txt in
|
||||||
* QEMU repository.
|
* QEMU repository.
|
||||||
*/
|
*/
|
||||||
const char *dev = qemuDeviceVideoTypeToString(video->type);
|
dev = qemuDeviceVideoTypeToString(video->type);
|
||||||
|
|
||||||
if (video->type == VIR_DOMAIN_VIDEO_TYPE_QXL &&
|
if (video->type == VIR_DOMAIN_VIDEO_TYPE_QXL &&
|
||||||
(video->vram || video->ram)) {
|
(video->vram || video->ram)) {
|
||||||
@ -4938,9 +4940,11 @@ qemuBuildChrChardevStr(virLogManagerPtr logManager,
|
|||||||
if (dev->data.nix.listen &&
|
if (dev->data.nix.listen &&
|
||||||
(flags & QEMU_BUILD_CHARDEV_UNIX_FD_PASS) &&
|
(flags & QEMU_BUILD_CHARDEV_UNIX_FD_PASS) &&
|
||||||
virQEMUCapsGet(qemuCaps, QEMU_CAPS_CHARDEV_FD_PASS)) {
|
virQEMUCapsGet(qemuCaps, QEMU_CAPS_CHARDEV_FD_PASS)) {
|
||||||
|
int fd;
|
||||||
|
|
||||||
if (qemuSecuritySetSocketLabel(secManager, (virDomainDefPtr)def) < 0)
|
if (qemuSecuritySetSocketLabel(secManager, (virDomainDefPtr)def) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
int fd = qemuOpenChrChardevUNIXSocket(dev);
|
fd = qemuOpenChrChardevUNIXSocket(dev);
|
||||||
if (qemuSecurityClearSocketLabel(secManager, (virDomainDefPtr)def) < 0) {
|
if (qemuSecurityClearSocketLabel(secManager, (virDomainDefPtr)def) < 0) {
|
||||||
VIR_FORCE_CLOSE(fd);
|
VIR_FORCE_CLOSE(fd);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -5019,11 +5019,12 @@ qemuProcessSetupRawIO(virQEMUDriverPtr driver,
|
|||||||
/* If rawio not already set, check hostdevs as well */
|
/* If rawio not already set, check hostdevs as well */
|
||||||
if (!rawio) {
|
if (!rawio) {
|
||||||
for (i = 0; i < vm->def->nhostdevs; i++) {
|
for (i = 0; i < vm->def->nhostdevs; i++) {
|
||||||
|
virDomainHostdevSubsysSCSIPtr scsisrc;
|
||||||
|
|
||||||
if (!virHostdevIsSCSIDevice(vm->def->hostdevs[i]))
|
if (!virHostdevIsSCSIDevice(vm->def->hostdevs[i]))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
virDomainHostdevSubsysSCSIPtr scsisrc =
|
scsisrc = &vm->def->hostdevs[i]->source.subsys.u.scsi;
|
||||||
&vm->def->hostdevs[i]->source.subsys.u.scsi;
|
|
||||||
if (scsisrc->rawio == VIR_TRISTATE_BOOL_YES) {
|
if (scsisrc->rawio == VIR_TRISTATE_BOOL_YES) {
|
||||||
rawio = true;
|
rawio = true;
|
||||||
break;
|
break;
|
||||||
|
@ -511,6 +511,8 @@ int virNetMessageEncodePayloadEmpty(virNetMessagePtr msg)
|
|||||||
|
|
||||||
void virNetMessageSaveError(virNetMessageErrorPtr rerr)
|
void virNetMessageSaveError(virNetMessageErrorPtr rerr)
|
||||||
{
|
{
|
||||||
|
virErrorPtr verr;
|
||||||
|
|
||||||
/* This func may be called several times & the first
|
/* This func may be called several times & the first
|
||||||
* error is the one we want because we don't want
|
* error is the one we want because we don't want
|
||||||
* cleanup code overwriting the first one.
|
* cleanup code overwriting the first one.
|
||||||
@ -519,7 +521,7 @@ void virNetMessageSaveError(virNetMessageErrorPtr rerr)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
memset(rerr, 0, sizeof(*rerr));
|
memset(rerr, 0, sizeof(*rerr));
|
||||||
virErrorPtr verr = virGetLastError();
|
verr = virGetLastError();
|
||||||
if (verr) {
|
if (verr) {
|
||||||
rerr->code = verr->code;
|
rerr->code = verr->code;
|
||||||
rerr->domain = verr->domain;
|
rerr->domain = verr->domain;
|
||||||
|
@ -325,6 +325,8 @@ int virNetSocketNewListenTCP(const char *nodename,
|
|||||||
int bindErrno = 0;
|
int bindErrno = 0;
|
||||||
virSocketAddr tmp_addr;
|
virSocketAddr tmp_addr;
|
||||||
int port = 0;
|
int port = 0;
|
||||||
|
int e;
|
||||||
|
struct addrinfo *runp;
|
||||||
|
|
||||||
*retsocks = NULL;
|
*retsocks = NULL;
|
||||||
*nretsocks = 0;
|
*nretsocks = 0;
|
||||||
@ -346,7 +348,7 @@ int virNetSocketNewListenTCP(const char *nodename,
|
|||||||
virSocketAddrIsWildcard(&tmp_addr)))
|
virSocketAddrIsWildcard(&tmp_addr)))
|
||||||
hints.ai_flags |= AI_ADDRCONFIG;
|
hints.ai_flags |= AI_ADDRCONFIG;
|
||||||
|
|
||||||
int e = getaddrinfo(nodename, service, &hints, &ai);
|
e = getaddrinfo(nodename, service, &hints, &ai);
|
||||||
if (e != 0) {
|
if (e != 0) {
|
||||||
virReportError(VIR_ERR_SYSTEM_ERROR,
|
virReportError(VIR_ERR_SYSTEM_ERROR,
|
||||||
_("Unable to resolve address '%s' service '%s': %s"),
|
_("Unable to resolve address '%s' service '%s': %s"),
|
||||||
@ -354,7 +356,7 @@ int virNetSocketNewListenTCP(const char *nodename,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct addrinfo *runp = ai;
|
runp = ai;
|
||||||
while (runp) {
|
while (runp) {
|
||||||
virSocketAddr addr;
|
virSocketAddr addr;
|
||||||
|
|
||||||
@ -587,6 +589,7 @@ int virNetSocketNewConnectTCP(const char *nodename,
|
|||||||
virSocketAddr remoteAddr;
|
virSocketAddr remoteAddr;
|
||||||
struct addrinfo *runp;
|
struct addrinfo *runp;
|
||||||
int savedErrno = ENOENT;
|
int savedErrno = ENOENT;
|
||||||
|
int e;
|
||||||
|
|
||||||
*retsock = NULL;
|
*retsock = NULL;
|
||||||
|
|
||||||
@ -598,7 +601,7 @@ int virNetSocketNewConnectTCP(const char *nodename,
|
|||||||
hints.ai_flags = AI_PASSIVE | AI_ADDRCONFIG | AI_V4MAPPED;
|
hints.ai_flags = AI_PASSIVE | AI_ADDRCONFIG | AI_V4MAPPED;
|
||||||
hints.ai_socktype = SOCK_STREAM;
|
hints.ai_socktype = SOCK_STREAM;
|
||||||
|
|
||||||
int e = getaddrinfo(nodename, service, &hints, &ai);
|
e = getaddrinfo(nodename, service, &hints, &ai);
|
||||||
if (e != 0) {
|
if (e != 0) {
|
||||||
virReportError(VIR_ERR_SYSTEM_ERROR,
|
virReportError(VIR_ERR_SYSTEM_ERROR,
|
||||||
_("Unable to resolve address '%s' service '%s': %s"),
|
_("Unable to resolve address '%s' service '%s': %s"),
|
||||||
|
@ -43,10 +43,12 @@ int
|
|||||||
virDaemonForkIntoBackground(const char *argv0)
|
virDaemonForkIntoBackground(const char *argv0)
|
||||||
{
|
{
|
||||||
int statuspipe[2];
|
int statuspipe[2];
|
||||||
|
pid_t pid;
|
||||||
|
|
||||||
if (virPipeQuiet(statuspipe) < 0)
|
if (virPipeQuiet(statuspipe) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
pid_t pid = fork();
|
pid = fork();
|
||||||
switch (pid) {
|
switch (pid) {
|
||||||
case 0:
|
case 0:
|
||||||
{
|
{
|
||||||
|
@ -1335,13 +1335,14 @@ void virReportSystemErrorFull(int domcode,
|
|||||||
|
|
||||||
if (fmt) {
|
if (fmt) {
|
||||||
va_list args;
|
va_list args;
|
||||||
|
size_t len;
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
n = g_vsnprintf(msgDetailBuf, sizeof(msgDetailBuf), fmt, args);
|
n = g_vsnprintf(msgDetailBuf, sizeof(msgDetailBuf), fmt, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
size_t len = strlen(errnoDetail);
|
len = strlen(errnoDetail);
|
||||||
if (0 <= n && n + 2 + len < sizeof(msgDetailBuf)) {
|
if (0 <= n && n + 2 + len < sizeof(msgDetailBuf)) {
|
||||||
strcpy(msgDetailBuf + n, ": ");
|
strcpy(msgDetailBuf + n, ": ");
|
||||||
n += 2;
|
n += 2;
|
||||||
|
@ -1412,13 +1412,16 @@ virFileReadLimFD(int fd, int maxlen, char **buf)
|
|||||||
int
|
int
|
||||||
virFileReadAll(const char *path, int maxlen, char **buf)
|
virFileReadAll(const char *path, int maxlen, char **buf)
|
||||||
{
|
{
|
||||||
int fd = open(path, O_RDONLY);
|
int fd;
|
||||||
|
int len;
|
||||||
|
|
||||||
|
fd = open(path, O_RDONLY);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
virReportSystemError(errno, _("Failed to open file '%s'"), path);
|
virReportSystemError(errno, _("Failed to open file '%s'"), path);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int len = virFileReadLimFD(fd, maxlen, buf);
|
len = virFileReadLimFD(fd, maxlen, buf);
|
||||||
VIR_FORCE_CLOSE(fd);
|
VIR_FORCE_CLOSE(fd);
|
||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
virReportSystemError(errno, _("Failed to read file '%s'"), path);
|
virReportSystemError(errno, _("Failed to read file '%s'"), path);
|
||||||
@ -1431,11 +1434,14 @@ virFileReadAll(const char *path, int maxlen, char **buf)
|
|||||||
int
|
int
|
||||||
virFileReadAllQuiet(const char *path, int maxlen, char **buf)
|
virFileReadAllQuiet(const char *path, int maxlen, char **buf)
|
||||||
{
|
{
|
||||||
int fd = open(path, O_RDONLY);
|
int fd;
|
||||||
|
int len;
|
||||||
|
|
||||||
|
fd = open(path, O_RDONLY);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
return -errno;
|
return -errno;
|
||||||
|
|
||||||
int len = virFileReadLimFD(fd, maxlen, buf);
|
len = virFileReadLimFD(fd, maxlen, buf);
|
||||||
VIR_FORCE_CLOSE(fd);
|
VIR_FORCE_CLOSE(fd);
|
||||||
if (len < 0)
|
if (len < 0)
|
||||||
return -errno;
|
return -errno;
|
||||||
|
@ -88,11 +88,13 @@ int virKeycodeValueFromString(virKeycodeSet codeset,
|
|||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
for (i = 0; i < VIR_KEYMAP_ENTRY_MAX; i++) {
|
for (i = 0; i < VIR_KEYMAP_ENTRY_MAX; i++) {
|
||||||
|
const char *name;
|
||||||
|
|
||||||
if (!virKeymapNames[codeset] ||
|
if (!virKeymapNames[codeset] ||
|
||||||
!virKeymapValues[codeset])
|
!virKeymapValues[codeset])
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const char *name = virKeymapNames[codeset][i];
|
name = virKeymapNames[codeset][i];
|
||||||
|
|
||||||
if (name && STREQ_NULLABLE(name, keyname))
|
if (name && STREQ_NULLABLE(name, keyname))
|
||||||
return virKeymapValues[codeset][i];
|
return virKeymapValues[codeset][i];
|
||||||
|
@ -817,10 +817,12 @@ virNetlinkEventServerUnlock(virNetlinkEventSrvPrivatePtr driver)
|
|||||||
static int
|
static int
|
||||||
virNetlinkEventRemoveClientPrimitive(size_t i, unsigned int protocol)
|
virNetlinkEventRemoveClientPrimitive(size_t i, unsigned int protocol)
|
||||||
{
|
{
|
||||||
|
virNetlinkEventRemoveCallback removeCB;
|
||||||
|
|
||||||
if (protocol >= MAX_LINKS)
|
if (protocol >= MAX_LINKS)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
virNetlinkEventRemoveCallback removeCB = server[protocol]->handles[i].removeCB;
|
removeCB = server[protocol]->handles[i].removeCB;
|
||||||
|
|
||||||
if (removeCB) {
|
if (removeCB) {
|
||||||
(removeCB)(server[protocol]->handles[i].watch,
|
(removeCB)(server[protocol]->handles[i].watch,
|
||||||
@ -890,11 +892,13 @@ virNetlinkEventCallback(int watch,
|
|||||||
int
|
int
|
||||||
virNetlinkEventServiceStop(unsigned int protocol)
|
virNetlinkEventServiceStop(unsigned int protocol)
|
||||||
{
|
{
|
||||||
|
virNetlinkEventSrvPrivatePtr srv;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
if (protocol >= MAX_LINKS)
|
if (protocol >= MAX_LINKS)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
virNetlinkEventSrvPrivatePtr srv = server[protocol];
|
srv = server[protocol];
|
||||||
size_t i;
|
|
||||||
|
|
||||||
VIR_INFO("stopping netlink event service");
|
VIR_INFO("stopping netlink event service");
|
||||||
|
|
||||||
|
@ -371,6 +371,7 @@ int virDiskNameParse(const char *name, int *disk, int *partition)
|
|||||||
int idx = 0;
|
int idx = 0;
|
||||||
static char const* const drive_prefix[] = {"fd", "hd", "vd", "sd", "xvd", "ubd"};
|
static char const* const drive_prefix[] = {"fd", "hd", "vd", "sd", "xvd", "ubd"};
|
||||||
size_t i;
|
size_t i;
|
||||||
|
size_t n_digits;
|
||||||
|
|
||||||
for (i = 0; i < G_N_ELEMENTS(drive_prefix); i++) {
|
for (i = 0; i < G_N_ELEMENTS(drive_prefix); i++) {
|
||||||
if (STRPREFIX(name, drive_prefix[i])) {
|
if (STRPREFIX(name, drive_prefix[i])) {
|
||||||
@ -391,8 +392,8 @@ int virDiskNameParse(const char *name, int *disk, int *partition)
|
|||||||
ptr++;
|
ptr++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Count the trailing digits. */
|
/* Count the trailing digits */
|
||||||
size_t n_digits = strspn(ptr, "0123456789");
|
n_digits = strspn(ptr, "0123456789");
|
||||||
if (ptr[n_digits] != '\0')
|
if (ptr[n_digits] != '\0')
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
@ -1911,10 +1912,11 @@ static int
|
|||||||
virPipeImpl(int fds[2], bool nonblock, bool errreport)
|
virPipeImpl(int fds[2], bool nonblock, bool errreport)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_PIPE2
|
#ifdef HAVE_PIPE2
|
||||||
|
int rv;
|
||||||
int flags = O_CLOEXEC;
|
int flags = O_CLOEXEC;
|
||||||
if (nonblock)
|
if (nonblock)
|
||||||
flags |= O_NONBLOCK;
|
flags |= O_NONBLOCK;
|
||||||
int rv = pipe2(fds, flags);
|
rv = pipe2(fds, flags);
|
||||||
#else /* !HAVE_PIPE2 */
|
#else /* !HAVE_PIPE2 */
|
||||||
# ifdef WIN32
|
# ifdef WIN32
|
||||||
int rv = _pipe(fds, 4096, _O_BINARY);
|
int rv = _pipe(fds, 4096, _O_BINARY);
|
||||||
|
@ -203,10 +203,11 @@ fakeParentDevice(void)
|
|||||||
static int
|
static int
|
||||||
addDevice(virNodeDeviceDefPtr def)
|
addDevice(virNodeDeviceDefPtr def)
|
||||||
{
|
{
|
||||||
|
virNodeDeviceObjPtr obj;
|
||||||
if (!def)
|
if (!def)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
virNodeDeviceObjPtr obj = virNodeDeviceObjListAssignDef(driver->devs, def);
|
obj = virNodeDeviceObjListAssignDef(driver->devs, def);
|
||||||
|
|
||||||
if (!obj) {
|
if (!obj) {
|
||||||
virNodeDeviceDefFree(def);
|
virNodeDeviceDefFree(def);
|
||||||
|
@ -90,6 +90,7 @@ testRange(const char *saddrstr, const char *eaddrstr,
|
|||||||
virSocketAddr saddr;
|
virSocketAddr saddr;
|
||||||
virSocketAddr eaddr;
|
virSocketAddr eaddr;
|
||||||
virSocketAddr netaddr;
|
virSocketAddr netaddr;
|
||||||
|
int gotsize;
|
||||||
|
|
||||||
if (virSocketAddrParse(&saddr, saddrstr, AF_UNSPEC) < 0)
|
if (virSocketAddrParse(&saddr, saddrstr, AF_UNSPEC) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
@ -98,8 +99,8 @@ testRange(const char *saddrstr, const char *eaddrstr,
|
|||||||
if (netstr && virSocketAddrParse(&netaddr, netstr, AF_UNSPEC) < 0)
|
if (netstr && virSocketAddrParse(&netaddr, netstr, AF_UNSPEC) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
int gotsize = virSocketAddrGetRange(&saddr, &eaddr,
|
gotsize = virSocketAddrGetRange(&saddr, &eaddr,
|
||||||
netstr ? &netaddr : NULL, prefix);
|
netstr ? &netaddr : NULL, prefix);
|
||||||
VIR_DEBUG("Size want %d vs got %d", size, gotsize);
|
VIR_DEBUG("Size want %d vs got %d", size, gotsize);
|
||||||
if (pass) {
|
if (pass) {
|
||||||
/* fail if virSocketAddrGetRange returns failure, or unexpected size */
|
/* fail if virSocketAddrGetRange returns failure, or unexpected size */
|
||||||
@ -136,6 +137,7 @@ static int testNetmask(const char *addr1str, const char *addr2str,
|
|||||||
virSocketAddr addr1;
|
virSocketAddr addr1;
|
||||||
virSocketAddr addr2;
|
virSocketAddr addr2;
|
||||||
virSocketAddr netmask;
|
virSocketAddr netmask;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (virSocketAddrParse(&addr1, addr1str, AF_UNSPEC) < 0)
|
if (virSocketAddrParse(&addr1, addr1str, AF_UNSPEC) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
@ -144,7 +146,7 @@ static int testNetmask(const char *addr1str, const char *addr2str,
|
|||||||
if (virSocketAddrParse(&netmask, netmaskstr, AF_UNSPEC) < 0)
|
if (virSocketAddrParse(&netmask, netmaskstr, AF_UNSPEC) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
int ret = virSocketAddrCheckNetmask(&addr1, &addr2, &netmask);
|
ret = virSocketAddrCheckNetmask(&addr1, &addr2, &netmask);
|
||||||
|
|
||||||
if (ret <= 0) {
|
if (ret <= 0) {
|
||||||
return pass ? -1 : 0;
|
return pass ? -1 : 0;
|
||||||
|
@ -124,9 +124,12 @@ static int testRotatingFileInitOne(const char *filename,
|
|||||||
VIR_DEBUG("Deleting %s", filename);
|
VIR_DEBUG("Deleting %s", filename);
|
||||||
unlink(filename);
|
unlink(filename);
|
||||||
} else {
|
} else {
|
||||||
VIR_DEBUG("Creating %s size %zu", filename, (size_t)size);
|
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
int fd = open(filename, O_WRONLY|O_CREAT|O_TRUNC, 0700);
|
int fd;
|
||||||
|
|
||||||
|
VIR_DEBUG("Creating %s size %zu", filename, (size_t)size);
|
||||||
|
|
||||||
|
fd = open(filename, O_WRONLY|O_CREAT|O_TRUNC, 0700);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
fprintf(stderr, "Cannot create %s\n", filename);
|
fprintf(stderr, "Cannot create %s\n", filename);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1757,6 +1757,7 @@ virshBlockJobWaitInit(vshControl *ctl,
|
|||||||
unsigned int timeout,
|
unsigned int timeout,
|
||||||
bool async_abort)
|
bool async_abort)
|
||||||
{
|
{
|
||||||
|
virConnectDomainEventGenericCallback cb;
|
||||||
virshBlockJobWaitDataPtr ret;
|
virshBlockJobWaitDataPtr ret;
|
||||||
virshControlPtr priv = ctl->privData;
|
virshControlPtr priv = ctl->privData;
|
||||||
|
|
||||||
@ -1774,8 +1775,7 @@ virshBlockJobWaitInit(vshControl *ctl,
|
|||||||
|
|
||||||
ret->status = -1;
|
ret->status = -1;
|
||||||
|
|
||||||
virConnectDomainEventGenericCallback cb =
|
cb = VIR_DOMAIN_EVENT_CALLBACK(virshBlockJobStatusHandler);
|
||||||
VIR_DOMAIN_EVENT_CALLBACK(virshBlockJobStatusHandler);
|
|
||||||
|
|
||||||
if ((ret->cb_id = virConnectDomainEventRegisterAny(priv->conn, dom,
|
if ((ret->cb_id = virConnectDomainEventRegisterAny(priv->conn, dom,
|
||||||
VIR_DOMAIN_EVENT_ID_BLOCK_JOB,
|
VIR_DOMAIN_EVENT_ID_BLOCK_JOB,
|
||||||
@ -7117,12 +7117,14 @@ virshParseCPUList(vshControl *ctl, int *cpumaplen,
|
|||||||
return NULL;
|
return NULL;
|
||||||
virBitmapSetAll(map);
|
virBitmapSetAll(map);
|
||||||
} else {
|
} else {
|
||||||
|
int lastcpu;
|
||||||
|
|
||||||
if (virBitmapParse(cpulist, &map, 1024) < 0 ||
|
if (virBitmapParse(cpulist, &map, 1024) < 0 ||
|
||||||
virBitmapIsAllClear(map)) {
|
virBitmapIsAllClear(map)) {
|
||||||
vshError(ctl, _("Invalid cpulist '%s'"), cpulist);
|
vshError(ctl, _("Invalid cpulist '%s'"), cpulist);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
int lastcpu = virBitmapLastSetBit(map);
|
lastcpu = virBitmapLastSetBit(map);
|
||||||
if (lastcpu >= maxcpu) {
|
if (lastcpu >= maxcpu) {
|
||||||
vshError(ctl, _("CPU %d in cpulist '%s' exceed the maxcpu %d"),
|
vshError(ctl, _("CPU %d in cpulist '%s' exceed the maxcpu %d"),
|
||||||
lastcpu, cpulist, maxcpu);
|
lastcpu, cpulist, maxcpu);
|
||||||
|
@ -275,12 +275,14 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd)
|
|||||||
|
|
||||||
/* Convert the snapshot parameters into backingStore XML */
|
/* Convert the snapshot parameters into backingStore XML */
|
||||||
if (snapshotStrVol) {
|
if (snapshotStrVol) {
|
||||||
|
virStorageVolPtr snapVol;
|
||||||
|
char *snapshotStrVolPath;
|
||||||
/* Lookup snapshot backing volume. Try the backing-vol
|
/* Lookup snapshot backing volume. Try the backing-vol
|
||||||
* parameter as a name */
|
* parameter as a name */
|
||||||
vshDebug(ctl, VSH_ERR_DEBUG,
|
vshDebug(ctl, VSH_ERR_DEBUG,
|
||||||
"%s: Look up backing store volume '%s' as name\n",
|
"%s: Look up backing store volume '%s' as name\n",
|
||||||
cmd->def->name, snapshotStrVol);
|
cmd->def->name, snapshotStrVol);
|
||||||
virStorageVolPtr snapVol = virStorageVolLookupByName(pool, snapshotStrVol);
|
snapVol = virStorageVolLookupByName(pool, snapshotStrVol);
|
||||||
if (snapVol)
|
if (snapVol)
|
||||||
vshDebug(ctl, VSH_ERR_DEBUG,
|
vshDebug(ctl, VSH_ERR_DEBUG,
|
||||||
"%s: Backing store volume found using '%s' as name\n",
|
"%s: Backing store volume found using '%s' as name\n",
|
||||||
@ -315,7 +317,6 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *snapshotStrVolPath;
|
|
||||||
if ((snapshotStrVolPath = virStorageVolGetPath(snapVol)) == NULL) {
|
if ((snapshotStrVolPath = virStorageVolGetPath(snapVol)) == NULL) {
|
||||||
virStorageVolFree(snapVol);
|
virStorageVolFree(snapVol);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
@ -428,11 +428,12 @@ dissect_libvirt_payload(tvbuff_t *tvb, proto_tree *tree,
|
|||||||
if (status == VIR_NET_OK) {
|
if (status == VIR_NET_OK) {
|
||||||
const vir_dissector_index_t *pds = get_program_data(prog, VIR_PROGRAM_DISSECTORS);
|
const vir_dissector_index_t *pds = get_program_data(prog, VIR_PROGRAM_DISSECTORS);
|
||||||
const gsize *len = get_program_data(prog, VIR_PROGRAM_DISSECTORS_LEN);
|
const gsize *len = get_program_data(prog, VIR_PROGRAM_DISSECTORS_LEN);
|
||||||
|
vir_xdr_dissector_t xd;
|
||||||
|
|
||||||
if (!len)
|
if (!len)
|
||||||
goto unknown;
|
goto unknown;
|
||||||
|
|
||||||
vir_xdr_dissector_t xd = find_payload_dissector(proc, type, pds, *len);
|
xd = find_payload_dissector(proc, type, pds, *len);
|
||||||
if (xd == NULL)
|
if (xd == NULL)
|
||||||
goto unknown;
|
goto unknown;
|
||||||
dissect_libvirt_payload_xdr_data(tvb, tree, payload_length, status, xd);
|
dissect_libvirt_payload_xdr_data(tvb, tree, payload_length, status, xd);
|
||||||
|
Loading…
Reference in New Issue
Block a user