aboutsummaryrefslogtreecommitdiff
path: root/qga/commands-win32.c
diff options
context:
space:
mode:
Diffstat (limited to 'qga/commands-win32.c')
-rw-r--r--qga/commands-win32.c40
1 files changed, 7 insertions, 33 deletions
diff --git a/qga/commands-win32.c b/qga/commands-win32.c
index ec9f55b..7d8d34d 100644
--- a/qga/commands-win32.c
+++ b/qga/commands-win32.c
@@ -193,8 +193,7 @@ static void handle_set_nonblocking(HANDLE fh)
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;
@@ -206,7 +205,7 @@ int64_t qmp_guest_file_open(const char *path, bool has_mode,
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);
@@ -317,14 +316,14 @@ static void execute_async(DWORD WINAPI (*func)(LPVOID), LPVOID opaque,
}
}
-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;
@@ -833,7 +832,6 @@ static void get_disk_properties(HANDLE vol_h, GuestDiskAddress *disk,
g_debug("serial number \"%s\"", serial);
if (*serial != 0) {
disk->serial = g_strndup(serial, len);
- disk->has_serial = true;
}
}
out_free:
@@ -951,7 +949,6 @@ static GuestDiskAddressList *build_guest_disk_info(char *guid, Error **errp)
/* 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) {
@@ -983,7 +980,6 @@ static GuestDiskAddressList *build_guest_disk_info(char *guid, Error **errp)
* 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);
@@ -1078,7 +1074,6 @@ GuestDiskInfoList *qmp_guest_get_disks(Error **errp)
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) {
@@ -1089,7 +1084,6 @@ GuestDiskInfoList *qmp_guest_get_disks(Error **errp)
address = NULL;
} else {
disk->address = address;
- disk->has_address = true;
}
QAPI_LIST_PREPEND(ret, disk);
@@ -1369,7 +1363,6 @@ qmp_guest_fstrim(bool has_minimum, int64_t minimum, Error **errp)
g_free(uc_path);
if (!path) {
- res->has_error = true;
res->error = g_strdup(gerr->message);
g_error_free(gerr);
break;
@@ -1387,7 +1380,6 @@ qmp_guest_fstrim(bool has_minimum, int64_t minimum, Error **errp)
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 {
@@ -1403,7 +1395,6 @@ qmp_guest_fstrim(bool has_minimum, int64_t minimum, Error **errp)
if (g_strstr_len(lines[i], -1, "(0x") == NULL) {
continue;
}
- res->has_error = true;
res->error = g_strdup(lines[i]);
break;
}
@@ -1683,8 +1674,6 @@ GuestNetworkInterfaceList *qmp_guest_network_get_interfaces(Error **errp)
(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;
@@ -1713,15 +1702,13 @@ GuestNetworkInterfaceList *qmp_guest_network_get_interfaces(Error **errp)
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;
}
}
}
@@ -2113,7 +2100,6 @@ GuestUserList *qmp_guest_get_users(Error **errp)
user->user = g_strdup(info->UserName);
user->domain = g_strdup(info->Domain);
- user->has_domain = true;
user->login_time = login_time;
@@ -2332,29 +2318,19 @@ GuestOSInfo *qmp_guest_get_osinfo(Error **errp)
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;
@@ -2478,7 +2454,6 @@ GuestDeviceInfoList *qmp_guest_get_devices(Error **errp)
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);
@@ -2502,7 +2477,6 @@ GuestDeviceInfoList *qmp_guest_get_devices(Error **errp)
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);