g_assert(rpid == pid);
}
-void qmp_guest_shutdown(bool has_mode, const char *mode, Error **errp)
+void qmp_guest_shutdown(const char *mode, Error **errp)
{
const char *shutdown_flag;
Error *local_err = NULL;
#endif
slog("guest-shutdown called, mode: %s", mode);
- if (!has_mode || strcmp(mode, "powerdown") == 0) {
+ if (!mode || strcmp(mode, "powerdown") == 0) {
shutdown_flag = powerdown_flag;
} else if (strcmp(mode, "halt") == 0) {
shutdown_flag = halt_flag;
return f;
}
-int64_t qmp_guest_file_open(const char *path, bool has_mode, const char *mode,
+int64_t qmp_guest_file_open(const char *path, const char *mode,
Error **errp)
{
FILE *fh;
Error *local_err = NULL;
int64_t handle;
- if (!has_mode) {
+ if (!mode) {
mode = "r";
}
slog("guest-file-open called, filepath: %s, mode: %s", path, mode);
return false;
}
- disk->has_ccw_address = true;
disk->ccw_address = g_new0(GuestCCWAddress, 1);
disk->ccw_address->cssid = cssid;
disk->ccw_address->ssid = ssid;
devnode = udev_device_get_devnode(udevice);
if (devnode != NULL) {
disk->dev = g_strdup(devnode);
- disk->has_dev = true;
}
serial = udev_device_get_property_value(udevice, "ID_SERIAL");
if (serial != NULL && *serial != 0) {
disk->serial = g_strdup(serial);
- disk->has_serial = true;
}
}
has_hwinf = false;
}
- if (has_hwinf || disk->has_dev || disk->has_serial) {
+ if (has_hwinf || disk->dev || disk->serial) {
QAPI_LIST_PREPEND(fs->disk, disk);
} else {
qapi_free_GuestDiskAddress(disk);
return;
}
- disk->has_smart = true;
disk->smart = g_new0(GuestDiskSmart, 1);
disk->smart->type = GUEST_DISK_BUS_TYPE_NVME;
static void get_disk_smart(GuestDiskInfo *disk)
{
- if (disk->has_address
+ if (disk->address
&& (disk->address->bus_type == GUEST_DISK_BUS_TYPE_NVME)) {
get_nvme_smart(disk);
}
disk->name = dev_name;
disk->partition = false;
disk->alias = get_alias_for_syspath(disk_dir);
- disk->has_alias = (disk->alias != NULL);
QAPI_LIST_PREPEND(ret, disk);
/* Get address for non-virtual devices */
error_get_pretty(local_err));
error_free(local_err);
local_err = NULL;
- } else if (disk->address != NULL) {
- disk->has_address = true;
}
}
if (fd == -1) {
result->error = g_strdup_printf("failed to open: %s",
strerror(errno));
- result->has_error = true;
continue;
}
r.minlen = has_minimum ? minimum : 0;
ret = ioctl(fd, FITRIM, &r);
if (ret == -1) {
- result->has_error = true;
if (errno == ENOTTY || errno == EOPNOTSUPP) {
result->error = g_strdup("trim not supported");
} else {
QAPI_LIST_APPEND(tail, info);
}
- if (!info->has_hardware_address) {
+ if (!info->hardware_address) {
if (!guest_get_hw_addr(ifa, mac_addr, &obtained, errp)) {
goto error;
}
(int) mac_addr[0], (int) mac_addr[1],
(int) mac_addr[2], (int) mac_addr[3],
(int) mac_addr[4], (int) mac_addr[5]);
- info->has_hardware_address = true;
}
}
info->has_ip_addresses = true;
- if (!info->has_statistics) {
+ if (!info->statistics) {
interface_stat = g_malloc0(sizeof(*interface_stat));
if (guest_get_network_stats(info->name, interface_stat) == -1) {
- info->has_statistics = false;
g_free(interface_stat);
} else {
info->statistics = interface_stat;
- info->has_statistics = true;
}
}
}
if (uname(&kinfo) != 0) {
error_setg_errno(errp, errno, "uname failed");
} else {
- info->has_kernel_version = true;
info->kernel_version = g_strdup(kinfo.version);
- info->has_kernel_release = true;
info->kernel_release = g_strdup(kinfo.release);
- info->has_machine = true;
info->machine = g_strdup(kinfo.machine);
}
value = g_key_file_get_value(osrelease, "os-release", osfield, NULL); \
if (value != NULL) { \
ga_osrelease_replace_special(value); \
- info->has_ ## field = true; \
info->field = value; \
} \
} while (0)
SetNamedPipeHandleState(fh, &pipe_state, NULL, NULL);
}
-int64_t qmp_guest_file_open(const char *path, bool has_mode,
- const char *mode, Error **errp)
+int64_t qmp_guest_file_open(const char *path, const char *mode, Error **errp)
{
int64_t fd = -1;
HANDLE fh;
GError *gerr = NULL;
wchar_t *w_path = NULL;
- if (!has_mode) {
+ if (!mode) {
mode = "r";
}
slog("guest-file-open called, filepath: %s, mode: %s", path, mode);
}
}
-void qmp_guest_shutdown(bool has_mode, const char *mode, Error **errp)
+void qmp_guest_shutdown(const char *mode, Error **errp)
{
Error *local_err = NULL;
UINT shutdown_flag = EWX_FORCE;
slog("guest-shutdown called, mode: %s", mode);
- if (!has_mode || strcmp(mode, "powerdown") == 0) {
+ if (!mode || strcmp(mode, "powerdown") == 0) {
shutdown_flag |= EWX_POWEROFF;
} else if (strcmp(mode, "halt") == 0) {
shutdown_flag |= EWX_SHUTDOWN;
g_debug("serial number \"%s\"", serial);
if (*serial != 0) {
disk->serial = g_strndup(serial, len);
- disk->has_serial = true;
}
}
out_free:
/* Possibly CD-ROM or a shared drive. Try to pass the volume */
g_debug("volume not on disk");
disk = g_new0(GuestDiskAddress, 1);
- disk->has_dev = true;
disk->dev = g_strdup(name);
get_single_disk_info(0xffffffff, disk, &local_err);
if (local_err) {
* See also Naming Files, Paths and Namespaces:
* https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file#win32-device-namespaces
*/
- disk->has_dev = true;
disk->dev = g_strdup_printf("\\\\.\\PhysicalDrive%lu",
extents->Extents[i].DiskNumber);
g_debug(" number: %lu", sdn.DeviceNumber);
address = g_new0(GuestDiskAddress, 1);
- address->has_dev = true;
address->dev = g_strdup(disk->name);
get_single_disk_info(sdn.DeviceNumber, address, &local_err);
if (local_err) {
address = NULL;
} else {
disk->address = address;
- disk->has_address = true;
}
QAPI_LIST_PREPEND(ret, disk);
g_free(uc_path);
if (!path) {
- res->has_error = true;
res->error = g_strdup(gerr->message);
g_error_free(gerr);
break;
if (!g_spawn_sync(NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL,
&out /* stdout */, NULL /* stdin */,
NULL, &gerr)) {
- res->has_error = true;
res->error = g_strdup(gerr->message);
g_error_free(gerr);
} else {
if (g_strstr_len(lines[i], -1, "(0x") == NULL) {
continue;
}
- res->has_error = true;
res->error = g_strdup(lines[i]);
break;
}
(int) mac_addr[0], (int) mac_addr[1],
(int) mac_addr[2], (int) mac_addr[3],
(int) mac_addr[4], (int) mac_addr[5]);
-
- info->has_hardware_address = true;
}
head_addr = NULL;
info->has_ip_addresses = true;
info->ip_addresses = head_addr;
}
- if (!info->has_statistics) {
+ if (!info->statistics) {
interface_stat = g_malloc0(sizeof(*interface_stat));
- if (guest_get_network_stats(addr->AdapterName,
- interface_stat) == -1) {
- info->has_statistics = false;
+ if (guest_get_network_stats(addr->AdapterName, interface_stat)
+ == -1) {
g_free(interface_stat);
} else {
info->statistics = interface_stat;
- info->has_statistics = true;
}
}
}
user->user = g_strdup(info->UserName);
user->domain = g_strdup(info->Domain);
- user->has_domain = true;
user->login_time = login_time;
info = g_new0(GuestOSInfo, 1);
- info->has_kernel_version = true;
info->kernel_version = g_strdup_printf("%lu.%lu",
os_version.dwMajorVersion,
os_version.dwMinorVersion);
- info->has_kernel_release = true;
info->kernel_release = g_strdup_printf("%lu",
os_version.dwBuildNumber);
- info->has_machine = true;
info->machine = ga_get_current_arch();
- info->has_id = true;
info->id = g_strdup("mswindows");
- info->has_name = true;
info->name = g_strdup("Microsoft Windows");
- info->has_pretty_name = true;
info->pretty_name = product_name;
- info->has_version = true;
info->version = ga_get_win_name(&os_version, false);
- info->has_version_id = true;
info->version_id = ga_get_win_name(&os_version, true);
- info->has_variant = true;
info->variant = g_strdup(server ? "server" : "client");
- info->has_variant_id = true;
info->variant_id = g_strdup(server ? "server" : "client");
return info;
device_id = g_match_info_fetch(match_info, 2);
device->id = g_new0(GuestDeviceId, 1);
- device->has_id = true;
device->id->type = GUEST_DEVICE_TYPE_PCI;
id = &device->id->u.pci;
id->vendor_id = g_ascii_strtoull(vendor_id, NULL, 16);
error_setg(errp, "conversion to utf8 failed (driver version)");
return NULL;
}
- device->has_driver_version = true;
date = (LPFILETIME)cm_get_property(dev_info_data.DevInst,
&qga_DEVPKEY_Device_DriverDate, &cm_type);
}
#endif
if (gei->out.length > 0) {
- ges->has_out_data = true;
ges->out_data = g_base64_encode(gei->out.data, gei->out.length);
g_free(gei->out.data);
ges->has_out_truncated = gei->out.truncated;
}
if (gei->err.length > 0) {
- ges->has_err_data = true;
ges->err_data = g_base64_encode(gei->err.data, gei->err.length);
g_free(gei->err.data);
ges->has_err_truncated = gei->err.truncated;
GuestExec *qmp_guest_exec(const char *path,
bool has_arg, strList *arg,
bool has_env, strList *env,
- bool has_input_data, const char *input_data,
+ const char *input_data,
bool has_capture_output, bool capture_output,
Error **errp)
{
arglist.value = (char *)path;
arglist.next = has_arg ? arg : NULL;
- if (has_input_data) {
+ if (input_data) {
input = qbase64_decode(input_data, -1, &ninput, errp);
if (!input) {
return NULL;
}
ret = g_spawn_async_with_pipes(NULL, argv, envp, flags,
- guest_exec_task_setup, NULL, &pid, has_input_data ? &in_fd : NULL,
+ guest_exec_task_setup, NULL, &pid, input_data ? &in_fd : NULL,
has_output ? &out_fd : NULL, has_output ? &err_fd : NULL, &gerr);
if (!ret) {
error_setg(errp, QERR_QGA_COMMAND_FAILED, gerr->message);
gei->has_output = has_output;
g_child_watch_add(pid, guest_exec_child_watch, gei);
- if (has_input_data) {
+ if (input_data) {
gei->in.data = g_steal_pointer(&input);
gei->in.size = ninput;
#ifdef G_OS_WIN32
info->offset = g_time_zone_get_offset(tz, intv);
name = g_time_zone_get_abbreviation(tz, intv);
if (name != NULL) {
- info->has_zone = true;
info->zone = g_strdup(name);
}
g_time_zone_unref(tz);
def need_has(self):
assert self.type
# Temporary hack to support dropping the has_FOO in reviewable chunks
- opt_out = [
- 'qga/qapi-schema.json']
+ opt_out = []
if self.info and any(self.info.fname.endswith(mod)
for mod in opt_out):
return self.optional