* [Qemu-devel] [PATCH 01/10] qga/commands-posix: Fix bug in guest-fstrim
2015-07-07 4:40 [Qemu-devel] [PULL 00/10] qemu-ga patches for 2.4.0 Michael Roth
@ 2015-07-07 4:40 ` Michael Roth
2015-07-07 4:40 ` [Qemu-devel] [PATCH 02/10] qga/qmp_guest_fstrim: Return per path fstrim result Michael Roth
` (9 subsequent siblings)
10 siblings, 0 replies; 26+ messages in thread
From: Michael Roth @ 2015-07-07 4:40 UTC (permalink / raw)
To: qemu-devel; +Cc: peter.maydell, Justin Ossevoort
From: Justin Ossevoort <justin@quarantainenet.nl>
The FITRIM ioctl updates the fstrim_range structure it receives. This
way the caller can determine how many bytes were trimmed. The
guest-fstrim logic reuses the same fstrim_range for each filesystem,
effectively limiting each filesystem to trim at most as much as the
previous was able to trim.
If a previous filesystem would have trimmed 0 bytes, than the next
filesystem would report an error 'Invalid argument' because a FITRIM
request with length 0 is not valid.
This change resets the fstrim_range structure for each filesystem.
Signed-off-by: Justin Ossevoort <justin@quarantainenet.nl>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
---
qga/commands-posix.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index befd00b..9ff33ec 100644
--- a/qga/commands-posix.c
+++ b/qga/commands-posix.c
@@ -1332,11 +1332,7 @@ void qmp_guest_fstrim(bool has_minimum, int64_t minimum, Error **errp)
struct FsMount *mount;
int fd;
Error *local_err = NULL;
- struct fstrim_range r = {
- .start = 0,
- .len = -1,
- .minlen = has_minimum ? minimum : 0,
- };
+ struct fstrim_range r;
slog("guest-fstrim called");
@@ -1360,6 +1356,9 @@ void qmp_guest_fstrim(bool has_minimum, int64_t minimum, Error **errp)
* error means an unexpected error, so return it in those cases. In
* some other cases ENOTTY will be reported (e.g. CD-ROMs).
*/
+ r.start = 0;
+ r.len = -1;
+ r.minlen = has_minimum ? minimum : 0;
ret = ioctl(fd, FITRIM, &r);
if (ret == -1) {
if (errno != ENOTTY && errno != EOPNOTSUPP) {
--
1.9.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [PATCH 02/10] qga/qmp_guest_fstrim: Return per path fstrim result
2015-07-07 4:40 [Qemu-devel] [PULL 00/10] qemu-ga patches for 2.4.0 Michael Roth
2015-07-07 4:40 ` [Qemu-devel] [PATCH 01/10] qga/commands-posix: Fix bug in guest-fstrim Michael Roth
@ 2015-07-07 4:40 ` Michael Roth
2015-07-07 4:40 ` [Qemu-devel] [PATCH 03/10] Revert "guest agent: remove g_strcmp0 usage" Michael Roth
` (8 subsequent siblings)
10 siblings, 0 replies; 26+ messages in thread
From: Michael Roth @ 2015-07-07 4:40 UTC (permalink / raw)
To: qemu-devel; +Cc: peter.maydell, Justin Ossevoort
From: Justin Ossevoort <justin@quarantainenet.nl>
The current guest-fstrim support only returns an error if some
mountpoint was unable to be trimmed, skipping any possible additional
mountpoints. The result of the TRIM operation itself is also discarded.
This change returns a per mountpoint result of the TRIM operation. If an
error occurs on some mountpoints that error is returned and the
guest-fstrim continue with any additional mountpoints.
The returned values for errors, minimum and trimmed are dependant on the
filesystem, storage stacks and kernel version.
Signed-off-by: Justin Ossevoort <justin@quarantainenet.nl>
* s/type/struct/ in schema type definitions
* moved version annotation for new guest-fstrim return field to
the field itself rather than applying to the entire command
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
---
qga/commands-posix.c | 54 ++++++++++++++++++++++++++++++++++++++--------------
qga/commands-win32.c | 4 +++-
qga/qapi-schema.json | 30 +++++++++++++++++++++++++++--
3 files changed, 71 insertions(+), 17 deletions(-)
diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index 9ff33ec..c349d4b 100644
--- a/qga/commands-posix.c
+++ b/qga/commands-posix.c
@@ -1325,8 +1325,12 @@ static void guest_fsfreeze_cleanup(void)
/*
* Walk list of mounted file systems in the guest, and trim them.
*/
-void qmp_guest_fstrim(bool has_minimum, int64_t minimum, Error **errp)
+GuestFilesystemTrimResponse *
+qmp_guest_fstrim(bool has_minimum, int64_t minimum, Error **errp)
{
+ GuestFilesystemTrimResponse *response;
+ GuestFilesystemTrimResultList *list;
+ GuestFilesystemTrimResult *result;
int ret = 0;
FsMountList mounts;
struct FsMount *mount;
@@ -1340,39 +1344,59 @@ void qmp_guest_fstrim(bool has_minimum, int64_t minimum, Error **errp)
build_fs_mount_list(&mounts, &local_err);
if (local_err) {
error_propagate(errp, local_err);
- return;
+ return NULL;
}
+ response = g_malloc0(sizeof(*response));
+
QTAILQ_FOREACH(mount, &mounts, next) {
+ result = g_malloc0(sizeof(*result));
+ result->path = g_strdup(mount->dirname);
+
+ list = g_malloc0(sizeof(*list));
+ list->value = result;
+ list->next = response->paths;
+ response->paths = list;
+
fd = qemu_open(mount->dirname, O_RDONLY);
if (fd == -1) {
- error_setg_errno(errp, errno, "failed to open %s", mount->dirname);
- goto error;
+ result->error = g_strdup_printf("failed to open: %s",
+ strerror(errno));
+ result->has_error = true;
+ continue;
}
/* We try to cull filesytems we know won't work in advance, but other
* filesytems may not implement fstrim for less obvious reasons. These
- * will report EOPNOTSUPP; we simply ignore these errors. Any other
- * error means an unexpected error, so return it in those cases. In
- * some other cases ENOTTY will be reported (e.g. CD-ROMs).
+ * will report EOPNOTSUPP; while in some other cases ENOTTY will be
+ * reported (e.g. CD-ROMs).
+ * Any other error means an unexpected error.
*/
r.start = 0;
r.len = -1;
r.minlen = has_minimum ? minimum : 0;
ret = ioctl(fd, FITRIM, &r);
if (ret == -1) {
- if (errno != ENOTTY && errno != EOPNOTSUPP) {
- error_setg_errno(errp, errno, "failed to trim %s",
- mount->dirname);
- close(fd);
- goto error;
+ result->has_error = true;
+ if (errno == ENOTTY || errno == EOPNOTSUPP) {
+ result->error = g_strdup("trim not supported");
+ } else {
+ result->error = g_strdup_printf("failed to trim: %s",
+ strerror(errno));
}
+ close(fd);
+ continue;
}
+
+ result->has_minimum = true;
+ result->minimum = r.minlen;
+ result->has_trimmed = true;
+ result->trimmed = r.len;
close(fd);
}
-error:
free_fs_mount_list(&mounts);
+ return response;
}
#endif /* CONFIG_FSTRIM */
@@ -2401,9 +2425,11 @@ int64_t qmp_guest_fsfreeze_thaw(Error **errp)
#endif /* CONFIG_FSFREEZE */
#if !defined(CONFIG_FSTRIM)
-void qmp_guest_fstrim(bool has_minimum, int64_t minimum, Error **errp)
+GuestFilesystemTrimResponse *
+qmp_guest_fstrim(bool has_minimum, int64_t minimum, Error **errp)
{
error_setg(errp, QERR_UNSUPPORTED);
+ return NULL;
}
#endif
diff --git a/qga/commands-win32.c b/qga/commands-win32.c
index fbddc8b..13679a1 100644
--- a/qga/commands-win32.c
+++ b/qga/commands-win32.c
@@ -493,9 +493,11 @@ static void guest_fsfreeze_cleanup(void)
* Walk list of mounted file systems in the guest, and discard unused
* areas.
*/
-void qmp_guest_fstrim(bool has_minimum, int64_t minimum, Error **errp)
+GuestFilesystemTrimResponse *
+qmp_guest_fstrim(bool has_minimum, int64_t minimum, Error **errp)
{
error_setg(errp, QERR_UNSUPPORTED);
+ return NULL;
}
typedef enum {
diff --git a/qga/qapi-schema.json b/qga/qapi-schema.json
index b446dc7..58cbf66 100644
--- a/qga/qapi-schema.json
+++ b/qga/qapi-schema.json
@@ -425,6 +425,30 @@
'returns': 'int' }
##
+# @GuestFilesystemTrimResult
+#
+# @path: path that was trimmed
+# @error: an error message when trim failed
+# @trimmed: bytes trimmed for this path
+# @minimum: reported effective minimum for this path
+#
+# Since: 2.4
+##
+{ 'struct': 'GuestFilesystemTrimResult',
+ 'data': {'path': 'str',
+ '*trimmed': 'int', '*minimum': 'int', '*error': 'str'} }
+
+##
+# @GuestFilesystemTrimResponse
+#
+# @paths: list of @GuestFilesystemTrimResult per path that was trimmed
+#
+# Since: 2.4
+##
+{ 'struct': 'GuestFilesystemTrimResponse',
+ 'data': {'paths': ['GuestFilesystemTrimResult']} }
+
+##
# @guest-fstrim:
#
# Discard (or "trim") blocks which are not in use by the filesystem.
@@ -437,12 +461,14 @@
# fragmented free space, although not all blocks will be discarded.
# The default value is zero, meaning "discard every free block".
#
-# Returns: Nothing.
+# Returns: A @GuestFilesystemTrimResponse which contains the
+# status of all trimmed paths. (since 2.4)
#
# Since: 1.2
##
{ 'command': 'guest-fstrim',
- 'data': { '*minimum': 'int' } }
+ 'data': { '*minimum': 'int' },
+ 'returns': 'GuestFilesystemTrimResponse' }
##
# @guest-suspend-disk
--
1.9.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [PATCH 03/10] Revert "guest agent: remove g_strcmp0 usage"
2015-07-07 4:40 [Qemu-devel] [PULL 00/10] qemu-ga patches for 2.4.0 Michael Roth
2015-07-07 4:40 ` [Qemu-devel] [PATCH 01/10] qga/commands-posix: Fix bug in guest-fstrim Michael Roth
2015-07-07 4:40 ` [Qemu-devel] [PATCH 02/10] qga/qmp_guest_fstrim: Return per path fstrim result Michael Roth
@ 2015-07-07 4:40 ` Michael Roth
2015-07-07 4:40 ` [Qemu-devel] [PATCH 04/10] qga: add win32 library iphlpapi Michael Roth
` (7 subsequent siblings)
10 siblings, 0 replies; 26+ messages in thread
From: Michael Roth @ 2015-07-07 4:40 UTC (permalink / raw)
To: qemu-devel; +Cc: peter.maydell, Markus Armbruster
From: Markus Armbruster <armbru@redhat.com>
Since we now require GLib 2.22+ (commit f40685c), we don't have to
work around lack of g_strcmp0() anymore.
This reverts commit 8f4774789947bc4bc4c8d026a289fe980d3d2ee1.
Conflicts:
qemu-ga.c
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
---
qga/main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/qga/main.c b/qga/main.c
index 23cde01..791982e 100644
--- a/qga/main.c
+++ b/qga/main.c
@@ -274,7 +274,7 @@ static void ga_log(const gchar *domain, GLogLevelFlags level,
level &= G_LOG_LEVEL_MASK;
#ifndef _WIN32
- if (domain && strcmp(domain, "syslog") == 0) {
+ if (g_strcmp0(domain, "syslog") == 0) {
syslog(LOG_INFO, "%s: %s", level_str, msg);
} else if (level & s->log_level) {
#else
--
1.9.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [PATCH 04/10] qga: add win32 library iphlpapi
2015-07-07 4:40 [Qemu-devel] [PULL 00/10] qemu-ga patches for 2.4.0 Michael Roth
` (2 preceding siblings ...)
2015-07-07 4:40 ` [Qemu-devel] [PATCH 03/10] Revert "guest agent: remove g_strcmp0 usage" Michael Roth
@ 2015-07-07 4:40 ` Michael Roth
2015-07-07 4:40 ` [Qemu-devel] [PATCH 05/10] qga: win32 qmp_guest_network_get_interfaces implementation Michael Roth
` (6 subsequent siblings)
10 siblings, 0 replies; 26+ messages in thread
From: Michael Roth @ 2015-07-07 4:40 UTC (permalink / raw)
To: qemu-devel; +Cc: peter.maydell, Kirk Allan
From: Kirk Allan <kallan@suse.com>
Add the iphlpapi library to use APIs such as GetAdaptersInfo and
GetAdaptersAddresses.
Signed-off-by: Kirk Allan <kallan@suse.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
---
configure | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/configure b/configure
index 3063739..3bb5e55 100755
--- a/configure
+++ b/configure
@@ -732,7 +732,7 @@ if test "$mingw32" = "yes" ; then
sysconfdir="\${prefix}"
local_statedir=
confsuffix=""
- libs_qga="-lws2_32 -lwinmm -lpowrprof $libs_qga"
+ libs_qga="-lws2_32 -lwinmm -lpowrprof -liphlpapi $libs_qga"
fi
werror=""
--
1.9.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [PATCH 05/10] qga: win32 qmp_guest_network_get_interfaces implementation
2015-07-07 4:40 [Qemu-devel] [PULL 00/10] qemu-ga patches for 2.4.0 Michael Roth
` (3 preceding siblings ...)
2015-07-07 4:40 ` [Qemu-devel] [PATCH 04/10] qga: add win32 library iphlpapi Michael Roth
@ 2015-07-07 4:40 ` Michael Roth
2015-07-07 4:40 ` [Qemu-devel] [PATCH 06/10] qga: fail early for invalid time Michael Roth
` (5 subsequent siblings)
10 siblings, 0 replies; 26+ messages in thread
From: Michael Roth @ 2015-07-07 4:40 UTC (permalink / raw)
To: qemu-devel; +Cc: peter.maydell, Kirk Allan
From: Kirk Allan <kallan@suse.com>
By default, IPv4 prefixes will be derived by matching the address
to those returned by GetAdaptersInfo. IPv6 prefixes can not be
matched this way due to the unpredictable order of entries.
In Windows Vista/2008 guests and newer, both IPv4 and IPv6 prefixes
can be retrieved from OnLinkPrefixLength. Setting --extra-cflags
in the build configuration to "-D_WIN32_WINNT=0x600"
or greater makes OnLinkPrefixLength available. Setting --extra-cflags
is not required and if not set, the default approach to get the prefix
will be taken.
Signed-off-by: Kirk Allan <kallan@suse.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
---
qga/commands-win32.c | 220 ++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 217 insertions(+), 3 deletions(-)
diff --git a/qga/commands-win32.c b/qga/commands-win32.c
index 13679a1..e8769bb 100644
--- a/qga/commands-win32.c
+++ b/qga/commands-win32.c
@@ -16,11 +16,17 @@
#include <powrprof.h>
#include <stdio.h>
#include <string.h>
+#include <winsock2.h>
+#include <ws2tcpip.h>
+#include <ws2ipdef.h>
+#include <iptypes.h>
+#include <iphlpapi.h>
#include "qga/guest-agent-core.h"
#include "qga/vss-win32.h"
#include "qga-qmp-commands.h"
#include "qapi/qmp/qerror.h"
#include "qemu/queue.h"
+#include "qemu/host-utils.h"
#ifndef SHTDN_REASON_FLAG_PLANNED
#define SHTDN_REASON_FLAG_PLANNED 0x80000000
@@ -591,12 +597,220 @@ void qmp_guest_suspend_hybrid(Error **errp)
error_setg(errp, QERR_UNSUPPORTED);
}
-GuestNetworkInterfaceList *qmp_guest_network_get_interfaces(Error **errp)
+static IP_ADAPTER_ADDRESSES *guest_get_adapters_addresses(Error **errp)
{
- error_setg(errp, QERR_UNSUPPORTED);
+ IP_ADAPTER_ADDRESSES *adptr_addrs = NULL;
+ ULONG adptr_addrs_len = 0;
+ DWORD ret;
+
+ /* Call the first time to get the adptr_addrs_len. */
+ GetAdaptersAddresses(AF_UNSPEC, GAA_FLAG_INCLUDE_PREFIX,
+ NULL, adptr_addrs, &adptr_addrs_len);
+
+ adptr_addrs = g_malloc(adptr_addrs_len);
+ ret = GetAdaptersAddresses(AF_UNSPEC, GAA_FLAG_INCLUDE_PREFIX,
+ NULL, adptr_addrs, &adptr_addrs_len);
+ if (ret != ERROR_SUCCESS) {
+ error_setg_win32(errp, ret, "failed to get adapters addresses");
+ g_free(adptr_addrs);
+ adptr_addrs = NULL;
+ }
+ return adptr_addrs;
+}
+
+static char *guest_wctomb_dup(WCHAR *wstr)
+{
+ char *str;
+ size_t i;
+
+ i = wcslen(wstr) + 1;
+ str = g_malloc(i);
+ WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK,
+ wstr, -1, str, i, NULL, NULL);
+ return str;
+}
+
+static char *guest_addr_to_str(IP_ADAPTER_UNICAST_ADDRESS *ip_addr,
+ Error **errp)
+{
+ char addr_str[INET6_ADDRSTRLEN + INET_ADDRSTRLEN];
+ DWORD len;
+ int ret;
+
+ if (ip_addr->Address.lpSockaddr->sa_family == AF_INET ||
+ ip_addr->Address.lpSockaddr->sa_family == AF_INET6) {
+ len = sizeof(addr_str);
+ ret = WSAAddressToString(ip_addr->Address.lpSockaddr,
+ ip_addr->Address.iSockaddrLength,
+ NULL,
+ addr_str,
+ &len);
+ if (ret != 0) {
+ error_setg_win32(errp, WSAGetLastError(),
+ "failed address presentation form conversion");
+ return NULL;
+ }
+ return g_strdup(addr_str);
+ }
return NULL;
}
+#if (_WIN32_WINNT >= 0x0600)
+static int64_t guest_ip_prefix(IP_ADAPTER_UNICAST_ADDRESS *ip_addr)
+{
+ /* For Windows Vista/2008 and newer, use the OnLinkPrefixLength
+ * field to obtain the prefix.
+ */
+ return ip_addr->OnLinkPrefixLength;
+}
+#else
+/* When using the Windows XP and 2003 build environment, do the best we can to
+ * figure out the prefix.
+ */
+static IP_ADAPTER_INFO *guest_get_adapters_info(void)
+{
+ IP_ADAPTER_INFO *adptr_info = NULL;
+ ULONG adptr_info_len = 0;
+ DWORD ret;
+
+ /* Call the first time to get the adptr_info_len. */
+ GetAdaptersInfo(adptr_info, &adptr_info_len);
+
+ adptr_info = g_malloc(adptr_info_len);
+ ret = GetAdaptersInfo(adptr_info, &adptr_info_len);
+ if (ret != ERROR_SUCCESS) {
+ g_free(adptr_info);
+ adptr_info = NULL;
+ }
+ return adptr_info;
+}
+
+static int64_t guest_ip_prefix(IP_ADAPTER_UNICAST_ADDRESS *ip_addr)
+{
+ int64_t prefix = -1; /* Use for AF_INET6 and unknown/undetermined values. */
+ IP_ADAPTER_INFO *adptr_info, *info;
+ IP_ADDR_STRING *ip;
+ struct in_addr *p;
+
+ if (ip_addr->Address.lpSockaddr->sa_family != AF_INET) {
+ return prefix;
+ }
+ adptr_info = guest_get_adapters_info();
+ if (adptr_info == NULL) {
+ return prefix;
+ }
+
+ /* Match up the passed in ip_addr with one found in adaptr_info.
+ * The matching one in adptr_info will have the netmask.
+ */
+ p = &((struct sockaddr_in *)ip_addr->Address.lpSockaddr)->sin_addr;
+ for (info = adptr_info; info; info = info->Next) {
+ for (ip = &info->IpAddressList; ip; ip = ip->Next) {
+ if (p->S_un.S_addr == inet_addr(ip->IpAddress.String)) {
+ prefix = ctpop32(inet_addr(ip->IpMask.String));
+ goto out;
+ }
+ }
+ }
+out:
+ g_free(adptr_info);
+ return prefix;
+}
+#endif
+
+GuestNetworkInterfaceList *qmp_guest_network_get_interfaces(Error **errp)
+{
+ IP_ADAPTER_ADDRESSES *adptr_addrs, *addr;
+ IP_ADAPTER_UNICAST_ADDRESS *ip_addr = NULL;
+ GuestNetworkInterfaceList *head = NULL, *cur_item = NULL;
+ GuestIpAddressList *head_addr, *cur_addr;
+ GuestNetworkInterfaceList *info;
+ GuestIpAddressList *address_item = NULL;
+ unsigned char *mac_addr;
+ char *addr_str;
+ WORD wsa_version;
+ WSADATA wsa_data;
+ int ret;
+
+ adptr_addrs = guest_get_adapters_addresses(errp);
+ if (adptr_addrs == NULL) {
+ return NULL;
+ }
+
+ /* Make WSA APIs available. */
+ wsa_version = MAKEWORD(2, 2);
+ ret = WSAStartup(wsa_version, &wsa_data);
+ if (ret != 0) {
+ error_setg_win32(errp, ret, "failed socket startup");
+ goto out;
+ }
+
+ for (addr = adptr_addrs; addr; addr = addr->Next) {
+ info = g_malloc0(sizeof(*info));
+
+ if (cur_item == NULL) {
+ head = cur_item = info;
+ } else {
+ cur_item->next = info;
+ cur_item = info;
+ }
+
+ info->value = g_malloc0(sizeof(*info->value));
+ info->value->name = guest_wctomb_dup(addr->FriendlyName);
+
+ if (addr->PhysicalAddressLength != 0) {
+ mac_addr = addr->PhysicalAddress;
+
+ info->value->hardware_address =
+ g_strdup_printf("%02x:%02x:%02x:%02x:%02x:%02x",
+ (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->value->has_hardware_address = true;
+ }
+
+ head_addr = NULL;
+ cur_addr = NULL;
+ for (ip_addr = addr->FirstUnicastAddress;
+ ip_addr;
+ ip_addr = ip_addr->Next) {
+ addr_str = guest_addr_to_str(ip_addr, errp);
+ if (addr_str == NULL) {
+ continue;
+ }
+
+ address_item = g_malloc0(sizeof(*address_item));
+
+ if (!cur_addr) {
+ head_addr = cur_addr = address_item;
+ } else {
+ cur_addr->next = address_item;
+ cur_addr = address_item;
+ }
+
+ address_item->value = g_malloc0(sizeof(*address_item->value));
+ address_item->value->ip_address = addr_str;
+ address_item->value->prefix = guest_ip_prefix(ip_addr);
+ if (ip_addr->Address.lpSockaddr->sa_family == AF_INET) {
+ address_item->value->ip_address_type =
+ GUEST_IP_ADDRESS_TYPE_IPV4;
+ } else if (ip_addr->Address.lpSockaddr->sa_family == AF_INET6) {
+ address_item->value->ip_address_type =
+ GUEST_IP_ADDRESS_TYPE_IPV6;
+ }
+ }
+ if (head_addr) {
+ info->value->has_ip_addresses = true;
+ info->value->ip_addresses = head_addr;
+ }
+ }
+ WSACleanup();
+out:
+ g_free(adptr_addrs);
+ return head;
+}
+
int64_t qmp_guest_get_time(Error **errp)
{
SYSTEMTIME ts = {0};
@@ -709,7 +923,7 @@ GuestMemoryBlockInfo *qmp_guest_get_memory_block_info(Error **errp)
GList *ga_command_blacklist_init(GList *blacklist)
{
const char *list_unsupported[] = {
- "guest-suspend-hybrid", "guest-network-get-interfaces",
+ "guest-suspend-hybrid",
"guest-get-vcpus", "guest-set-vcpus",
"guest-set-user-password",
"guest-get-memory-blocks", "guest-set-memory-blocks",
--
1.9.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [PATCH 06/10] qga: fail early for invalid time
2015-07-07 4:40 [Qemu-devel] [PULL 00/10] qemu-ga patches for 2.4.0 Michael Roth
` (4 preceding siblings ...)
2015-07-07 4:40 ` [Qemu-devel] [PATCH 05/10] qga: win32 qmp_guest_network_get_interfaces implementation Michael Roth
@ 2015-07-07 4:40 ` Michael Roth
2015-07-07 4:40 ` [Qemu-devel] [PATCH 07/10] qga: added empty qmp_quest_get_fsinfo functionality Michael Roth
` (4 subsequent siblings)
10 siblings, 0 replies; 26+ messages in thread
From: Michael Roth @ 2015-07-07 4:40 UTC (permalink / raw)
To: qemu-devel; +Cc: peter.maydell, Marc-André Lureau
From: Marc-André Lureau <marcandre.lureau@redhat.com>
It's possible to set system time with dates after 2070, however, it's
not possible to set the RTC. It has limitation to up to year
2070 (1970+100). In order to keep both clock in sync and before the
kernel complains on invalid values, bail out early.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
---
qga/commands-posix.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index c349d4b..675f4b4 100644
--- a/qga/commands-posix.c
+++ b/qga/commands-posix.c
@@ -154,6 +154,8 @@ void qmp_guest_set_time(bool has_time, int64_t time_ns, Error **errp)
/* If user has passed a time, validate and set it. */
if (has_time) {
+ GDate date = { 0, };
+
/* year-2038 will overflow in case time_t is 32bit */
if (time_ns / 1000000000 != (time_t)(time_ns / 1000000000)) {
error_setg(errp, "Time %" PRId64 " is too large", time_ns);
@@ -162,6 +164,11 @@ void qmp_guest_set_time(bool has_time, int64_t time_ns, Error **errp)
tv.tv_sec = time_ns / 1000000000;
tv.tv_usec = (time_ns % 1000000000) / 1000;
+ g_date_set_time_t(&date, tv.tv_sec);
+ if (date.year < 1970 || date.year >= 2070) {
+ error_setg_errno(errp, errno, "Invalid time");
+ return;
+ }
ret = settimeofday(&tv, NULL);
if (ret < 0) {
--
1.9.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [PATCH 07/10] qga: added empty qmp_quest_get_fsinfo functionality.
2015-07-07 4:40 [Qemu-devel] [PULL 00/10] qemu-ga patches for 2.4.0 Michael Roth
` (5 preceding siblings ...)
2015-07-07 4:40 ` [Qemu-devel] [PATCH 06/10] qga: fail early for invalid time Michael Roth
@ 2015-07-07 4:40 ` Michael Roth
2015-07-07 4:40 ` [Qemu-devel] [PATCH 08/10] qga: added mountpoint and filesystem type for single volume Michael Roth
` (3 subsequent siblings)
10 siblings, 0 replies; 26+ messages in thread
From: Michael Roth @ 2015-07-07 4:40 UTC (permalink / raw)
To: qemu-devel; +Cc: Denis V. Lunev, peter.maydell, Olga Krishtal
From: Olga Krishtal <okrishtal@virtuozzo.com>
We need qmp_quest_get_fsinfo togather with vss-provider, which works with
volumes. The call to this function is implemented via
FindFirst/NextVolumes. Moreover, volumes in Windows OS are filesystem unit,
so it will be more effective to work with them rather with devices.
Signed-off-by: Olga Krishtal <okrishtal@virtuozzo.com>
Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: Eric Blake <eblake@redhat.com>
CC: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
---
qga/commands-win32.c | 27 ++++++++++++++++++++++++---
1 file changed, 24 insertions(+), 3 deletions(-)
diff --git a/qga/commands-win32.c b/qga/commands-win32.c
index e8769bb..3f3a144 100644
--- a/qga/commands-win32.c
+++ b/qga/commands-win32.c
@@ -390,8 +390,29 @@ static void guest_file_init(void)
GuestFilesystemInfoList *qmp_guest_get_fsinfo(Error **errp)
{
- error_setg(errp, QERR_UNSUPPORTED);
- return NULL;
+ HANDLE vol_h;
+ GuestFilesystemInfoList *new, *ret = NULL;
+ char guid[256];
+
+ vol_h = FindFirstVolume(guid, sizeof(guid));
+ if (vol_h == INVALID_HANDLE_VALUE) {
+ error_setg_win32(errp, GetLastError(), "failed to find any volume");
+ return NULL;
+ }
+
+ do {
+ new = g_malloc(sizeof(*ret));
+ new->value = build_guest_fsinfo(guid, errp);
+ new->next = ret;
+ ret = new;
+ } while (FindNextVolume(vol_h, guid, sizeof(guid)));
+
+ if (GetLastError() != ERROR_NO_MORE_FILES) {
+ error_setg_win32(errp, GetLastError(), "failed to find next volume");
+ }
+
+ FindVolumeClose(vol_h);
+ return ret;
}
/*
@@ -928,7 +949,7 @@ GList *ga_command_blacklist_init(GList *blacklist)
"guest-set-user-password",
"guest-get-memory-blocks", "guest-set-memory-blocks",
"guest-get-memory-block-size",
- "guest-fsfreeze-freeze-list", "guest-get-fsinfo",
+ "guest-fsfreeze-freeze-list",
"guest-fstrim", NULL};
char **p = (char **)list_unsupported;
--
1.9.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [PATCH 08/10] qga: added mountpoint and filesystem type for single volume
2015-07-07 4:40 [Qemu-devel] [PULL 00/10] qemu-ga patches for 2.4.0 Michael Roth
` (6 preceding siblings ...)
2015-07-07 4:40 ` [Qemu-devel] [PATCH 07/10] qga: added empty qmp_quest_get_fsinfo functionality Michael Roth
@ 2015-07-07 4:40 ` Michael Roth
2015-07-07 4:40 ` [Qemu-devel] [PATCH 09/10] qga: added bus type and disk location path Michael Roth
` (2 subsequent siblings)
10 siblings, 0 replies; 26+ messages in thread
From: Michael Roth @ 2015-07-07 4:40 UTC (permalink / raw)
To: qemu-devel; +Cc: Denis V. Lunev, peter.maydell, Olga Krishtal
From: Olga Krishtal <okrishtal@virtuozzo.com>
We should use GetVolumeXXX api to work with volumes. This will help us to
resolve the situation with volumes without drive letter, i.e. when the
volume is mounted as a folder. Such volume is called mounted folder.
This volume is a regular mounted volume from all other points of view.
The information about non mounted volume is reported as System Reserved.
This volume is not mounted and thus it is not writable.
GuestDiskAddressList API is not used because operations are performed with
volumes but no with disks. This means that spanned disk will
be counted and handled as a single volume. It is worth mentioning
that the information about every disk in the volume can be queried
via IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS.
Signed-off-by: Olga Krishtal <okrishtal@virtuozzo.com>
Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: Eric Blake <eblake@redhat.com>
CC: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
---
qga/commands-win32.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 53 insertions(+), 1 deletion(-)
diff --git a/qga/commands-win32.c b/qga/commands-win32.c
index 3f3a144..60d9770 100644
--- a/qga/commands-win32.c
+++ b/qga/commands-win32.c
@@ -388,6 +388,54 @@ static void guest_file_init(void)
QTAILQ_INIT(&guest_file_state.filehandles);
}
+static GuestFilesystemInfo *build_guest_fsinfo(char *guid, Error **errp)
+{
+ DWORD info_size;
+ char mnt, *mnt_point;
+ char fs_name[32];
+ char vol_info[MAX_PATH+1];
+ size_t len;
+ GuestFilesystemInfo *fs = NULL;
+
+ GetVolumePathNamesForVolumeName(guid, (LPCH)&mnt, 0, &info_size);
+ if (GetLastError() != ERROR_MORE_DATA) {
+ error_setg_win32(errp, GetLastError(), "failed to get volume name");
+ return NULL;
+ }
+
+ mnt_point = g_malloc(info_size + 1);
+ if (!GetVolumePathNamesForVolumeName(guid, mnt_point, info_size,
+ &info_size)) {
+ error_setg_win32(errp, GetLastError(), "failed to get volume name");
+ goto free;
+ }
+
+ len = strlen(mnt_point);
+ mnt_point[len] = '\\';
+ mnt_point[len+1] = 0;
+ if (!GetVolumeInformation(mnt_point, vol_info, sizeof(vol_info), NULL, NULL,
+ NULL, (LPSTR)&fs_name, sizeof(fs_name))) {
+ if (GetLastError() != ERROR_NOT_READY) {
+ error_setg_win32(errp, GetLastError(), "failed to get volume info");
+ }
+ goto free;
+ }
+
+ fs_name[sizeof(fs_name) - 1] = 0;
+ fs = g_malloc(sizeof(*fs));
+ fs->name = g_strdup(guid);
+ if (len == 0) {
+ fs->mountpoint = g_strdup("System Reserved");
+ } else {
+ fs->mountpoint = g_strndup(mnt_point, len);
+ }
+ fs->type = g_strdup(fs_name);
+ fs->disk = NULL;
+free:
+ g_free(mnt_point);
+ return fs;
+}
+
GuestFilesystemInfoList *qmp_guest_get_fsinfo(Error **errp)
{
HANDLE vol_h;
@@ -401,8 +449,12 @@ GuestFilesystemInfoList *qmp_guest_get_fsinfo(Error **errp)
}
do {
+ GuestFilesystemInfo *info = build_guest_fsinfo(guid, errp);
+ if (info == NULL) {
+ continue;
+ }
new = g_malloc(sizeof(*ret));
- new->value = build_guest_fsinfo(guid, errp);
+ new->value = info;
new->next = ret;
ret = new;
} while (FindNextVolume(vol_h, guid, sizeof(guid)));
--
1.9.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* [Qemu-devel] [PATCH 09/10] qga: added bus type and disk location path
2015-07-07 4:40 [Qemu-devel] [PULL 00/10] qemu-ga patches for 2.4.0 Michael Roth
` (7 preceding siblings ...)
2015-07-07 4:40 ` [Qemu-devel] [PATCH 08/10] qga: added mountpoint and filesystem type for single volume Michael Roth
@ 2015-07-07 4:40 ` Michael Roth
2015-07-20 15:06 ` Eric Blake
2015-07-07 4:40 ` [Qemu-devel] [PATCH 10/10] qga: added GuestPCIAddress information Michael Roth
2015-07-07 10:32 ` [Qemu-devel] [PULL 00/10] qemu-ga patches for 2.4.0 Peter Maydell
10 siblings, 1 reply; 26+ messages in thread
From: Michael Roth @ 2015-07-07 4:40 UTC (permalink / raw)
To: qemu-devel; +Cc: Denis V. Lunev, peter.maydell, Olga Krishtal
From: Olga Krishtal <okrishtal@virtuozzo.com>
According to Microsoft disk location path can be obtained via
IOCTL_SCSI_GET_ADDRESS. Unfortunately this ioctl can not be used for all
devices. There are certain bus types which could be obtained with this
API. Please, refer to the following link for more details
https://technet.microsoft.com/en-us/library/ee851589(v=ws.10).aspx
Bus type could be obtained using IOCTL_STORAGE_QUERY_PROPERTY. Enum
STORAGE_BUS_TYPE describes all buses supported by OS.
Windows defines more bus types than Linux. Thus some values have been added
to GuestDiskBusType.
Signed-off-by: Olga Krishtal <okrishtal@virtuozzo.com>
Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: Eric Blake <eblake@redhat.com>
CC: Michael Roth <mdroth@linux.vnet.ibm.com>
* fixed warning in CreateFile due to use of NULL instead of 0
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
---
qga/commands-win32.c | 122 ++++++++++++++++++++++++++++++++++++++++++++++++++-
qga/qapi-schema.json | 14 +++++-
2 files changed, 134 insertions(+), 2 deletions(-)
diff --git a/qga/commands-win32.c b/qga/commands-win32.c
index 60d9770..bffa766 100644
--- a/qga/commands-win32.c
+++ b/qga/commands-win32.c
@@ -21,6 +21,8 @@
#include <ws2ipdef.h>
#include <iptypes.h>
#include <iphlpapi.h>
+#include <winioctl.h>
+#include <ntddscsi.h>
#include "qga/guest-agent-core.h"
#include "qga/vss-win32.h"
#include "qga-qmp-commands.h"
@@ -90,6 +92,37 @@ static OpenFlags *find_open_flag(const char *mode_str)
return NULL;
}
+static STORAGE_BUS_TYPE win2qemu[] = {
+ [BusTypeUnknown] = GUEST_DISK_BUS_TYPE_UNKNOWN,
+ [BusTypeScsi] = GUEST_DISK_BUS_TYPE_SCSI,
+ [BusTypeAtapi] = GUEST_DISK_BUS_TYPE_IDE,
+ [BusTypeAta] = GUEST_DISK_BUS_TYPE_IDE,
+ [BusType1394] = GUEST_DISK_BUS_TYPE_IEEE1394,
+ [BusTypeSsa] = GUEST_DISK_BUS_TYPE_SSA,
+ [BusTypeFibre] = GUEST_DISK_BUS_TYPE_SSA,
+ [BusTypeUsb] = GUEST_DISK_BUS_TYPE_USB,
+ [BusTypeRAID] = GUEST_DISK_BUS_TYPE_RAID,
+#if (_WIN32_WINNT >= 0x0600)
+ [BusTypeiScsi] = GUEST_DISK_BUS_TYPE_ISCSI,
+ [BusTypeSas] = GUEST_DISK_BUS_TYPE_SAS,
+ [BusTypeSata] = GUEST_DISK_BUS_TYPE_SATA,
+ [BusTypeSd] = GUEST_DISK_BUS_TYPE_SD,
+ [BusTypeMmc] = GUEST_DISK_BUS_TYPE_MMC,
+#endif
+#if (_WIN32_WINNT >= 0x0601)
+ [BusTypeVirtual] = GUEST_DISK_BUS_TYPE_VIRTUAL,
+ [BusTypeFileBackedVirtual] = GUEST_DISK_BUS_TYPE_FILE_BACKED_VIRTUAL,
+#endif
+};
+
+static GuestDiskBusType find_bus_type(STORAGE_BUS_TYPE bus)
+{
+ if (bus > ARRAY_SIZE(win2qemu) || (int)bus < 0) {
+ return GUEST_DISK_BUS_TYPE_UNKNOWN;
+ }
+ return win2qemu[(int)bus];
+}
+
static int64_t guest_file_handle_add(HANDLE fh, Error **errp)
{
GuestFileHandle *gfh;
@@ -388,6 +421,93 @@ static void guest_file_init(void)
QTAILQ_INIT(&guest_file_state.filehandles);
}
+static GuestPCIAddress *get_pci_info(char *guid, Error **errp)
+{
+ return NULL;
+}
+
+static int get_disk_bus_type(HANDLE vol_h, Error **errp)
+{
+ STORAGE_PROPERTY_QUERY query;
+ STORAGE_DEVICE_DESCRIPTOR *dev_desc, buf;
+ DWORD received;
+
+ dev_desc = &buf;
+ dev_desc->Size = sizeof(buf);
+ query.PropertyId = StorageDeviceProperty;
+ query.QueryType = PropertyStandardQuery;
+
+ if (!DeviceIoControl(vol_h, IOCTL_STORAGE_QUERY_PROPERTY, &query,
+ sizeof(STORAGE_PROPERTY_QUERY), dev_desc,
+ dev_desc->Size, &received, NULL)) {
+ error_setg_win32(errp, GetLastError(), "failed to get bus type");
+ return -1;
+ }
+
+ return dev_desc->BusType;
+}
+
+/* VSS provider works with volumes, thus there is no difference if
+ * the volume consist of spanned disks. Info about the first disk in the
+ * volume is returned for the spanned disk group (LVM) */
+static GuestDiskAddressList *build_guest_disk_info(char *guid, Error **errp)
+{
+ GuestDiskAddressList *list = NULL;
+ GuestDiskAddress *disk;
+ SCSI_ADDRESS addr, *scsi_ad;
+ DWORD len;
+ int bus;
+ HANDLE vol_h;
+
+ scsi_ad = &addr;
+ char *name = g_strndup(guid, strlen(guid)-1);
+
+ vol_h = CreateFile(name, 0, FILE_SHARE_READ, NULL, OPEN_EXISTING,
+ 0, NULL);
+ if (vol_h == INVALID_HANDLE_VALUE) {
+ error_setg_win32(errp, GetLastError(), "failed to open volume");
+ goto out_free;
+ }
+
+ bus = get_disk_bus_type(vol_h, errp);
+ if (bus < 0) {
+ goto out_close;
+ }
+
+ disk = g_malloc0(sizeof(*disk));
+ disk->bus_type = find_bus_type(bus);
+ if (bus == BusTypeScsi || bus == BusTypeAta || bus == BusTypeRAID
+#if (_WIN32_WINNT >= 0x0600)
+ /* This bus type is not supported before Windows Server 2003 SP1 */
+ || bus == BusTypeSas
+#endif
+ ) {
+ /* We are able to use the same ioctls for different bus types
+ * according to Microsoft docs
+ * https://technet.microsoft.com/en-us/library/ee851589(v=ws.10).aspx */
+ if (DeviceIoControl(vol_h, IOCTL_SCSI_GET_ADDRESS, NULL, 0, scsi_ad,
+ sizeof(SCSI_ADDRESS), &len, NULL)) {
+ disk->unit = addr.Lun;
+ disk->target = addr.TargetId;
+ disk->bus = addr.PathId;
+ disk->pci_controller = get_pci_info(name, errp);
+ }
+ /* We do not set error in this case, because we still have enough
+ * information about volume. */
+ } else {
+ disk->pci_controller = NULL;
+ }
+
+ list = g_malloc0(sizeof(*list));
+ list->value = disk;
+ list->next = NULL;
+out_close:
+ CloseHandle(vol_h);
+out_free:
+ g_free(name);
+ return list;
+}
+
static GuestFilesystemInfo *build_guest_fsinfo(char *guid, Error **errp)
{
DWORD info_size;
@@ -430,7 +550,7 @@ static GuestFilesystemInfo *build_guest_fsinfo(char *guid, Error **errp)
fs->mountpoint = g_strndup(mnt_point, len);
}
fs->type = g_strdup(fs_name);
- fs->disk = NULL;
+ fs->disk = build_guest_disk_info(guid, errp);;
free:
g_free(mnt_point);
return fs;
diff --git a/qga/qapi-schema.json b/qga/qapi-schema.json
index 58cbf66..8a9b818 100644
--- a/qga/qapi-schema.json
+++ b/qga/qapi-schema.json
@@ -703,12 +703,24 @@
# @uml: UML disks
# @sata: SATA disks
# @sd: SD cards
+# @unknown: Unknown bus type
+# @ieee1394: Win IEEE 1394 bus type
+# @ssa: Win SSA bus type
+# @fibre: Win fiber channel bus type
+# @raid: Win RAID bus type
+# @iscsi: Win iScsi bus type
+# @sas: Win serial-attaches SCSI bus type
+# @mmc: Win multimedia card (MMC) bus type
+# @virtual: Win virtual bus type
+# @file-backed virtual: Win file-backed bus type
#
# Since: 2.2
##
{ 'enum': 'GuestDiskBusType',
'data': [ 'ide', 'fdc', 'scsi', 'virtio', 'xen', 'usb', 'uml', 'sata',
- 'sd' ] }
+ 'sd', 'unknown', 'ieee1394', 'ssa', 'fibre', 'raid', 'iscsi',
+ 'sas', 'mmc', 'virtual', 'file-backed-virtual' ] }
+
##
# @GuestPCIAddress:
--
1.9.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* Re: [Qemu-devel] [PATCH 09/10] qga: added bus type and disk location path
2015-07-07 4:40 ` [Qemu-devel] [PATCH 09/10] qga: added bus type and disk location path Michael Roth
@ 2015-07-20 15:06 ` Eric Blake
2015-07-20 15:19 ` Denis V. Lunev
0 siblings, 1 reply; 26+ messages in thread
From: Eric Blake @ 2015-07-20 15:06 UTC (permalink / raw)
To: Michael Roth, qemu-devel; +Cc: Denis V. Lunev, Olga Krishtal, peter.maydell
[-- Attachment #1: Type: text/plain, Size: 1819 bytes --]
On 07/06/2015 10:40 PM, Michael Roth wrote:
> From: Olga Krishtal <okrishtal@virtuozzo.com>
>
> According to Microsoft disk location path can be obtained via
> IOCTL_SCSI_GET_ADDRESS. Unfortunately this ioctl can not be used for all
> devices. There are certain bus types which could be obtained with this
> API. Please, refer to the following link for more details
> https://technet.microsoft.com/en-us/library/ee851589(v=ws.10).aspx
>
> Bus type could be obtained using IOCTL_STORAGE_QUERY_PROPERTY. Enum
> STORAGE_BUS_TYPE describes all buses supported by OS.
>
> Windows defines more bus types than Linux. Thus some values have been added
> to GuestDiskBusType.
>
> Signed-off-by: Olga Krishtal <okrishtal@virtuozzo.com>
> Signed-off-by: Denis V. Lunev <den@openvz.org>
> CC: Eric Blake <eblake@redhat.com>
> CC: Michael Roth <mdroth@linux.vnet.ibm.com>
> * fixed warning in CreateFile due to use of NULL instead of 0
> Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
> ---
> +++ b/qga/qapi-schema.json
> @@ -703,12 +703,24 @@
> # @uml: UML disks
> # @sata: SATA disks
> # @sd: SD cards
> +# @unknown: Unknown bus type
> +# @ieee1394: Win IEEE 1394 bus type
> +# @ssa: Win SSA bus type
> +# @fibre: Win fiber channel bus type
> +# @raid: Win RAID bus type
> +# @iscsi: Win iScsi bus type
> +# @sas: Win serial-attaches SCSI bus type
> +# @mmc: Win multimedia card (MMC) bus type
> +# @virtual: Win virtual bus type
> +# @file-backed virtual: Win file-backed bus type
> #
> # Since: 2.2
It would be nice to have a followup patch (since it is doc-only, it
could still make 2.4) that mentions that all these new enum members were
added in 2.4.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [Qemu-devel] [PATCH 09/10] qga: added bus type and disk location path
2015-07-20 15:06 ` Eric Blake
@ 2015-07-20 15:19 ` Denis V. Lunev
0 siblings, 0 replies; 26+ messages in thread
From: Denis V. Lunev @ 2015-07-20 15:19 UTC (permalink / raw)
To: Eric Blake, Michael Roth, qemu-devel; +Cc: peter.maydell, Olga Krishtal
[-- Attachment #1: Type: text/plain, Size: 1759 bytes --]
On 07/20/2015 06:06 PM, Eric Blake wrote:
> On 07/06/2015 10:40 PM, Michael Roth wrote:
>> From: Olga Krishtal <okrishtal@virtuozzo.com>
>>
>> According to Microsoft disk location path can be obtained via
>> IOCTL_SCSI_GET_ADDRESS. Unfortunately this ioctl can not be used for all
>> devices. There are certain bus types which could be obtained with this
>> API. Please, refer to the following link for more details
>> https://technet.microsoft.com/en-us/library/ee851589(v=ws.10).aspx
>>
>> Bus type could be obtained using IOCTL_STORAGE_QUERY_PROPERTY. Enum
>> STORAGE_BUS_TYPE describes all buses supported by OS.
>>
>> Windows defines more bus types than Linux. Thus some values have been added
>> to GuestDiskBusType.
>>
>> Signed-off-by: Olga Krishtal <okrishtal@virtuozzo.com>
>> Signed-off-by: Denis V. Lunev <den@openvz.org>
>> CC: Eric Blake <eblake@redhat.com>
>> CC: Michael Roth <mdroth@linux.vnet.ibm.com>
>> * fixed warning in CreateFile due to use of NULL instead of 0
>> Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
>> ---
>> +++ b/qga/qapi-schema.json
>> @@ -703,12 +703,24 @@
>> # @uml: UML disks
>> # @sata: SATA disks
>> # @sd: SD cards
>> +# @unknown: Unknown bus type
>> +# @ieee1394: Win IEEE 1394 bus type
>> +# @ssa: Win SSA bus type
>> +# @fibre: Win fiber channel bus type
>> +# @raid: Win RAID bus type
>> +# @iscsi: Win iScsi bus type
>> +# @sas: Win serial-attaches SCSI bus type
>> +# @mmc: Win multimedia card (MMC) bus type
>> +# @virtual: Win virtual bus type
>> +# @file-backed virtual: Win file-backed bus type
>> #
>> # Since: 2.2
> It would be nice to have a followup patch (since it is doc-only, it
> could still make 2.4) that mentions that all these new enum members were
> added in 2.4.
>
sure!
[-- Attachment #2: Type: text/html, Size: 2788 bytes --]
^ permalink raw reply [flat|nested] 26+ messages in thread
* [Qemu-devel] [PATCH 10/10] qga: added GuestPCIAddress information
2015-07-07 4:40 [Qemu-devel] [PULL 00/10] qemu-ga patches for 2.4.0 Michael Roth
` (8 preceding siblings ...)
2015-07-07 4:40 ` [Qemu-devel] [PATCH 09/10] qga: added bus type and disk location path Michael Roth
@ 2015-07-07 4:40 ` Michael Roth
2015-07-07 10:32 ` [Qemu-devel] [PULL 00/10] qemu-ga patches for 2.4.0 Peter Maydell
10 siblings, 0 replies; 26+ messages in thread
From: Michael Roth @ 2015-07-07 4:40 UTC (permalink / raw)
To: qemu-devel; +Cc: Denis V. Lunev, peter.maydell, Olga Krishtal
From: Olga Krishtal <okrishtal@virtuozzo.com>
PCIAddress inforfation is obtained via SetupApi, which provides the
information about address, bus, etc. We look throught entire device tree
in the system and try to find device object for given volume. For this PDO
SetupDiGetDeviceRegistryProperty is called, which reads PCI configuration
for a given devicei if it is possible.
This is the most convinient way for a userspace service. The lookup is
performed for every volume available. However, this information is
not mandatory for vss-provider.
In order to use SetupApi we need to notify linker about it. We do not need
to install additional libs, so we do not make separate configuration
option to use libsetupapi.su
SetupApi gives as the same information as kernel driver
with IRP_MN_QUERY_INTERFACE.
https://support.microsoft.com/en-us/kb/253232
Signed-off-by: Olga Krishtal <okrishtal@virtuozzo.com>
Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: Eric Blake <eblake@redhat.com>
CC: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
---
configure | 2 +-
qga/commands-win32.c | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 97 insertions(+), 2 deletions(-)
diff --git a/configure b/configure
index 3bb5e55..5fb8919 100755
--- a/configure
+++ b/configure
@@ -732,7 +732,7 @@ if test "$mingw32" = "yes" ; then
sysconfdir="\${prefix}"
local_statedir=
confsuffix=""
- libs_qga="-lws2_32 -lwinmm -lpowrprof -liphlpapi $libs_qga"
+ libs_qga="-lsetupapi -lws2_32 -lwinmm -lpowrprof -liphlpapi $libs_qga"
fi
werror=""
diff --git a/qga/commands-win32.c b/qga/commands-win32.c
index bffa766..609f3c7 100644
--- a/qga/commands-win32.c
+++ b/qga/commands-win32.c
@@ -23,6 +23,8 @@
#include <iphlpapi.h>
#include <winioctl.h>
#include <ntddscsi.h>
+#include <setupapi.h>
+#include <initguid.h>
#include "qga/guest-agent-core.h"
#include "qga/vss-win32.h"
#include "qga-qmp-commands.h"
@@ -34,6 +36,10 @@
#define SHTDN_REASON_FLAG_PLANNED 0x80000000
#endif
+DEFINE_GUID(GUID_DEVINTERFACE_VOLUME,
+ 0x53f5630dL, 0xb6bf, 0x11d0, 0x94, 0xf2,
+ 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
+
/* multiple of 100 nanoseconds elapsed between windows baseline
* (1/1/1601) and Unix Epoch (1/1/1970), accounting for leap years */
#define W32_FT_OFFSET (10000000ULL * 60 * 60 * 24 * \
@@ -423,7 +429,96 @@ static void guest_file_init(void)
static GuestPCIAddress *get_pci_info(char *guid, Error **errp)
{
- return NULL;
+ HDEVINFO dev_info;
+ SP_DEVINFO_DATA dev_info_data;
+ DWORD size = 0;
+ int i;
+ char dev_name[MAX_PATH];
+ char *buffer = NULL;
+ GuestPCIAddress *pci = NULL;
+ char *name = g_strdup(&guid[4]);
+
+ if (!QueryDosDevice(name, dev_name, ARRAY_SIZE(dev_name))) {
+ error_setg_win32(errp, GetLastError(), "failed to get dos device name");
+ goto out;
+ }
+
+ dev_info = SetupDiGetClassDevs(&GUID_DEVINTERFACE_VOLUME, 0, 0,
+ DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
+ if (dev_info == INVALID_HANDLE_VALUE) {
+ error_setg_win32(errp, GetLastError(), "failed to get devices tree");
+ goto out;
+ }
+
+ dev_info_data.cbSize = sizeof(SP_DEVINFO_DATA);
+ for (i = 0; SetupDiEnumDeviceInfo(dev_info, i, &dev_info_data); i++) {
+ DWORD addr, bus, slot, func, dev, data, size2;
+ while (!SetupDiGetDeviceRegistryProperty(dev_info, &dev_info_data,
+ SPDRP_PHYSICAL_DEVICE_OBJECT_NAME,
+ &data, (PBYTE)buffer, size,
+ &size2)) {
+ size = MAX(size, size2);
+ if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
+ g_free(buffer);
+ /* Double the size to avoid problems on
+ * W2k MBCS systems per KB 888609.
+ * https://support.microsoft.com/en-us/kb/259695 */
+ buffer = g_malloc(size * 2);
+ } else {
+ error_setg_win32(errp, GetLastError(),
+ "failed to get device name");
+ goto out;
+ }
+ }
+
+ if (g_strcmp0(buffer, dev_name)) {
+ continue;
+ }
+
+ /* There is no need to allocate buffer in the next functions. The size
+ * is known and ULONG according to
+ * https://support.microsoft.com/en-us/kb/253232
+ * https://msdn.microsoft.com/en-us/library/windows/hardware/ff543095(v=vs.85).aspx
+ */
+ if (!SetupDiGetDeviceRegistryProperty(dev_info, &dev_info_data,
+ SPDRP_BUSNUMBER, &data, (PBYTE)&bus, size, NULL)) {
+ break;
+ }
+
+ /* The function retrieves the device's address. This value will be
+ * transformed into device function and number */
+ if (!SetupDiGetDeviceRegistryProperty(dev_info, &dev_info_data,
+ SPDRP_ADDRESS, &data, (PBYTE)&addr, size, NULL)) {
+ break;
+ }
+
+ /* This call returns UINumber of DEVICE_CAPABILITIES structure.
+ * This number is typically a user-perceived slot number. */
+ if (!SetupDiGetDeviceRegistryProperty(dev_info, &dev_info_data,
+ SPDRP_UI_NUMBER, &data, (PBYTE)&slot, size, NULL)) {
+ break;
+ }
+
+ /* SetupApi gives us the same information as driver with
+ * IoGetDeviceProperty. According to Microsoft
+ * https://support.microsoft.com/en-us/kb/253232
+ * FunctionNumber = (USHORT)((propertyAddress) & 0x0000FFFF);
+ * DeviceNumber = (USHORT)(((propertyAddress) >> 16) & 0x0000FFFF);
+ * SPDRP_ADDRESS is propertyAddress, so we do the same.*/
+
+ func = addr & 0x0000FFFF;
+ dev = (addr >> 16) & 0x0000FFFF;
+ pci = g_malloc0(sizeof(*pci));
+ pci->domain = dev;
+ pci->slot = slot;
+ pci->function = func;
+ pci->bus = bus;
+ break;
+ }
+out:
+ g_free(buffer);
+ g_free(name);
+ return pci;
}
static int get_disk_bus_type(HANDLE vol_h, Error **errp)
--
1.9.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* Re: [Qemu-devel] [PULL 00/10] qemu-ga patches for 2.4.0
2015-07-07 4:40 [Qemu-devel] [PULL 00/10] qemu-ga patches for 2.4.0 Michael Roth
` (9 preceding siblings ...)
2015-07-07 4:40 ` [Qemu-devel] [PATCH 10/10] qga: added GuestPCIAddress information Michael Roth
@ 2015-07-07 10:32 ` Peter Maydell
2015-07-07 13:06 ` Olga Krishtal
2015-07-07 13:25 ` Olga Krishtal
10 siblings, 2 replies; 26+ messages in thread
From: Peter Maydell @ 2015-07-07 10:32 UTC (permalink / raw)
To: Michael Roth; +Cc: QEMU Developers
On 7 July 2015 at 05:40, Michael Roth <mdroth@linux.vnet.ibm.com> wrote:
> Hi Peter,
>
> Sorry for the last minute pull. This is a round-up of all tested/reviewed
> qemu-ga patches posted prior to soft-freeze, along with 1 bug fix that
> came in last week.
>
> This adds win32 implementations of:
> guest-get-fsinfo
> guest-network-get-interfaces
>
> and modifies guest-fstrim to return per-mount results and continue on to other
> mounts even when a failure is encountered.
>
> There's also bug fixes for guest-fstrim and guest-set-time.
>
> The following changes since commit 7edd8e4660beb301d527257f8e04ebec0f841cb0:
>
> Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging (2015-07-06 14:03:44 +0100)
>
> are available in the git repository at:
>
>
> git://github.com/mdroth/qemu.git tags/qga-pull-2015-07-06-tag
>
> for you to fetch changes up to d1ad92aab4a9419538b7b1b7423a8a770c7a2859:
>
> qga: added GuestPCIAddress information (2015-07-06 23:06:12 -0500)
>
> ----------------------------------------------------------------
> tag for qga-pull-2015-07-06
Hi. I'm afraid this doesn't build for me for Windows:
/home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:21:22:
error: ws2ipdef.h: No such file or directory
CC qga/vss-win32.o
CC qga/qapi-generated/qga-qapi-types.o
/home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:25:22:
error: ntddscsi.h: No such file or directory
CC qga/qapi-generated/qga-qapi-visit.o
CC qga/qapi-generated/qga-qmp-marshal.o
cc1: warnings being treated as errors
/home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:39:
warning: ‘GUID_DEVINTERFACE_VOLUME’ initialized and declared ‘extern’
/home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:101: error:
expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘win2qemu’
/home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:124: error:
expected ‘)’ before ‘bus’
AR libqemuutil.a
/home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c: In
function ‘get_disk_bus_type’:
/home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:526: error:
‘STORAGE_PROPERTY_QUERY’ undeclared (first use in this function)
/home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:526: error:
(Each undeclared identifier is reported only once
/home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:526: error:
for each function it appears in.)
/home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:526: error:
expected ‘;’ before ‘query’
/home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:527: error:
‘STORAGE_DEVICE_DESCRIPTOR’ undeclared (first use in this function)
/home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:527: error:
‘dev_desc’ undeclared (first use in this function)
/home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:527: error:
‘buf’ undeclared (first use in this function)
/home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:527:
warning: left-hand operand of comma expression has no effect
/home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:532: error:
‘query’ undeclared (first use in this function)
/home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:532: error:
‘StorageDeviceProperty’ undeclared (first use in this function)
/home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:533: error:
‘PropertyStandardQuery’ undeclared (first use in this function)
/home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:535: error:
‘IOCTL_STORAGE_QUERY_PROPERTY’ undeclared (first use in this function)
/home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:543:
warning: control reaches end of non-void function
/home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c: In
function ‘build_guest_disk_info’:
/home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:552: error:
‘SCSI_ADDRESS’ undeclared (first use in this function)
/home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:552: error:
expected ‘;’ before ‘addr’
/home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:557: error:
‘scsi_ad’ undeclared (first use in this function)
/home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:557: error:
‘addr’ undeclared (first use in this function)
/home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:573:
warning: implicit declaration of function ‘find_bus_type’
/home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:573:
warning: nested extern declaration of ‘find_bus_type’
/home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:574: error:
‘BusTypeScsi’ undeclared (first use in this function)
/home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:574: error:
‘BusTypeAta’ undeclared (first use in this function)
/home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:574: error:
‘BusTypeRAID’ undeclared (first use in this function)
/home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:583: error:
‘IOCTL_SCSI_GET_ADDRESS’ undeclared (first use in this function)
make: *** [qga/commands-win32.o] Error 1
thanks
-- PMM
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [Qemu-devel] [PULL 00/10] qemu-ga patches for 2.4.0
2015-07-07 10:32 ` [Qemu-devel] [PULL 00/10] qemu-ga patches for 2.4.0 Peter Maydell
@ 2015-07-07 13:06 ` Olga Krishtal
2015-07-07 13:15 ` Peter Maydell
2015-07-07 13:18 ` Peter Maydell
2015-07-07 13:25 ` Olga Krishtal
1 sibling, 2 replies; 26+ messages in thread
From: Olga Krishtal @ 2015-07-07 13:06 UTC (permalink / raw)
To: Peter Maydell, Michael Roth; +Cc: QEMU Developers
On 07/07/15 13:32, Peter Maydell wrote:
> On 7 July 2015 at 05:40, Michael Roth <mdroth@linux.vnet.ibm.com> wrote:
>> Hi Peter,
>>
>> Sorry for the last minute pull. This is a round-up of all tested/reviewed
>> qemu-ga patches posted prior to soft-freeze, along with 1 bug fix that
>> came in last week.
>>
>> This adds win32 implementations of:
>> guest-get-fsinfo
>> guest-network-get-interfaces
>>
>> and modifies guest-fstrim to return per-mount results and continue on to other
>> mounts even when a failure is encountered.
>>
>> There's also bug fixes for guest-fstrim and guest-set-time.
>>
>> The following changes since commit 7edd8e4660beb301d527257f8e04ebec0f841cb0:
>>
>> Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging (2015-07-06 14:03:44 +0100)
>>
>> are available in the git repository at:
>>
>>
>> git://github.com/mdroth/qemu.git tags/qga-pull-2015-07-06-tag
>>
>> for you to fetch changes up to d1ad92aab4a9419538b7b1b7423a8a770c7a2859:
>>
>> qga: added GuestPCIAddress information (2015-07-06 23:06:12 -0500)
>>
>> ----------------------------------------------------------------
>> tag for qga-pull-2015-07-06
> Hi. I'm afraid this doesn't build for me for Windows:
>
> /home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:21:22:
> error: ws2ipdef.h: No such file or directory
> CC qga/vss-win32.o
> CC qga/qapi-generated/qga-qapi-types.o
> /home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:25:22:
> error: ntddscsi.h: No such file or directory
I am using the following mingw cross
[gray_pig@gray qemu]$ rpm -qf
/usr/x86_64-w64-mingw32/sys-root/mingw/include/ntddscsi.h
mingw64-headers-4.0.2-1.el7.noarch
Do we have minimal version which should be supported for the
case? If so, should we use config option for this or bump
minimal version?
IMHO this is the root of all problems below.
> CC qga/qapi-generated/qga-qapi-visit.o
> CC qga/qapi-generated/qga-qmp-marshal.o
> cc1: warnings being treated as errors
> /home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:39:
> warning: ‘GUID_DEVINTERFACE_VOLUME’ initialized and declared ‘extern’
> /home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:101: error:
> expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘win2qemu’
> /home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:124: error:
> expected ‘)’ before ‘bus’
> AR libqemuutil.a
> /home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c: In
> function ‘get_disk_bus_type’:
> /home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:526: error:
> ‘STORAGE_PROPERTY_QUERY’ undeclared (first use in this function)
> /home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:526: error:
> (Each undeclared identifier is reported only once
> /home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:526: error:
> for each function it appears in.)
> /home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:526: error:
> expected ‘;’ before ‘query’
> /home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:527: error:
> ‘STORAGE_DEVICE_DESCRIPTOR’ undeclared (first use in this function)
> /home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:527: error:
> ‘dev_desc’ undeclared (first use in this function)
> /home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:527: error:
> ‘buf’ undeclared (first use in this function)
> /home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:527:
> warning: left-hand operand of comma expression has no effect
> /home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:532: error:
> ‘query’ undeclared (first use in this function)
> /home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:532: error:
> ‘StorageDeviceProperty’ undeclared (first use in this function)
> /home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:533: error:
> ‘PropertyStandardQuery’ undeclared (first use in this function)
> /home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:535: error:
> ‘IOCTL_STORAGE_QUERY_PROPERTY’ undeclared (first use in this function)
> /home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:543:
> warning: control reaches end of non-void function
> /home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c: In
> function ‘build_guest_disk_info’:
> /home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:552: error:
> ‘SCSI_ADDRESS’ undeclared (first use in this function)
>
To link the part of code connected with setupapi we use -lsetupapi option.
It seems you are missing this lib.
> /home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:552: error:
> expected ‘;’ before ‘addr’
> /home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:557: error:
> ‘scsi_ad’ undeclared (first use in this function)
> /home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:557: error:
> ‘addr’ undeclared (first use in this function)
> /home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:573:
> warning: implicit declaration of function ‘find_bus_type’
> /home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:573:
> warning: nested extern declaration of ‘find_bus_type’
> /home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:574: error:
> ‘BusTypeScsi’ undeclared (first use in this function)
> /home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:574: error:
> ‘BusTypeAta’ undeclared (first use in this function)
> /home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:574: error:
> ‘BusTypeRAID’ undeclared (first use in this function)
> /home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:583: error:
> ‘IOCTL_SCSI_GET_ADDRESS’ undeclared (first use in this function)
> make: *** [qga/commands-win32.o] Error 1
>
> thanks
> -- PMM
>
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [Qemu-devel] [PULL 00/10] qemu-ga patches for 2.4.0
2015-07-07 13:06 ` Olga Krishtal
@ 2015-07-07 13:15 ` Peter Maydell
2015-07-07 13:18 ` Peter Maydell
1 sibling, 0 replies; 26+ messages in thread
From: Peter Maydell @ 2015-07-07 13:15 UTC (permalink / raw)
To: Olga Krishtal; +Cc: Michael Roth, QEMU Developers
On 7 July 2015 at 14:06, Olga Krishtal <okrishtal@parallels.com> wrote:
> On 07/07/15 13:32, Peter Maydell wrote:
>>
>> On 7 July 2015 at 05:40, Michael Roth <mdroth@linux.vnet.ibm.com> wrote:
>>>
>>> Hi Peter,
>>>
>>> Sorry for the last minute pull. This is a round-up of all tested/reviewed
>>> qemu-ga patches posted prior to soft-freeze, along with 1 bug fix that
>>> came in last week.
>>>
>>> This adds win32 implementations of:
>>> guest-get-fsinfo
>>> guest-network-get-interfaces
>>>
>>> and modifies guest-fstrim to return per-mount results and continue on to
>>> other
>>> mounts even when a failure is encountered.
>>>
>>> There's also bug fixes for guest-fstrim and guest-set-time.
>>>
>>> The following changes since commit
>>> 7edd8e4660beb301d527257f8e04ebec0f841cb0:
>>>
>>> Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into
>>> staging (2015-07-06 14:03:44 +0100)
>>>
>>> are available in the git repository at:
>>>
>>>
>>> git://github.com/mdroth/qemu.git tags/qga-pull-2015-07-06-tag
>>>
>>> for you to fetch changes up to d1ad92aab4a9419538b7b1b7423a8a770c7a2859:
>>>
>>> qga: added GuestPCIAddress information (2015-07-06 23:06:12 -0500)
>>>
>>> ----------------------------------------------------------------
>>> tag for qga-pull-2015-07-06
>>
>> Hi. I'm afraid this doesn't build for me for Windows:
>>
>> /home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:21:22:
>> error: ws2ipdef.h: No such file or directory
>> CC qga/vss-win32.o
>> CC qga/qapi-generated/qga-qapi-types.o
>> /home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:25:22:
>> error: ntddscsi.h: No such file or directory
>
> I am using the following mingw cross
> [gray_pig@gray qemu]$ rpm -qf
> /usr/x86_64-w64-mingw32/sys-root/mingw/include/ntddscsi.h
> mingw64-headers-4.0.2-1.el7.noarch
>
> Do we have minimal version which should be supported for the
> case? If so, should we use config option for this or bump
> minimal version?
>
> IMHO this is the root of all problems below.
Yes, my windows build environment is a fairly old one
(ubuntu host, mingw32-runtime 3.15.2-0ubuntu1).
It looks like in older versions of mingw this header is
in ddk/ntddscsi.h, see for instance:
http://sourceforge.net/p/mingw-w64/mailman/mingw-w64-public/thread/4C1E3BCE.6090901@yahoo.de/
It's OK if we make new features dependent on having a
newer mingw, but you need to have a configure check
to make sure the things you depend on exist.
thanks
-- PMM
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [Qemu-devel] [PULL 00/10] qemu-ga patches for 2.4.0
2015-07-07 13:06 ` Olga Krishtal
2015-07-07 13:15 ` Peter Maydell
@ 2015-07-07 13:18 ` Peter Maydell
1 sibling, 0 replies; 26+ messages in thread
From: Peter Maydell @ 2015-07-07 13:18 UTC (permalink / raw)
To: Olga Krishtal; +Cc: Stefan Weil, Michael Roth, QEMU Developers
On 7 July 2015 at 14:06, Olga Krishtal <okrishtal@parallels.com> wrote:
> Do we have minimal version which should be supported for the
> case? If so, should we use config option for this or bump
> minimal version?
Incidentally, I don't inherently object to bumping the
minimum version of mingw or whatever here; that's a
decision for the win32 maintainer. I would prefer that
we don't make the change on the eve of hardfreeze, though...
thanks
-- PMM
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [Qemu-devel] [PULL 00/10] qemu-ga patches for 2.4.0
2015-07-07 10:32 ` [Qemu-devel] [PULL 00/10] qemu-ga patches for 2.4.0 Peter Maydell
2015-07-07 13:06 ` Olga Krishtal
@ 2015-07-07 13:25 ` Olga Krishtal
2015-07-07 13:30 ` Peter Maydell
1 sibling, 1 reply; 26+ messages in thread
From: Olga Krishtal @ 2015-07-07 13:25 UTC (permalink / raw)
To: Peter Maydell, Michael Roth; +Cc: QEMU Developers
On 07/07/15 13:32, Peter Maydell wrote:
> On 7 July 2015 at 05:40, Michael Roth <mdroth@linux.vnet.ibm.com> wrote:
>> Hi Peter,
>>
>> Sorry for the last minute pull. This is a round-up of all tested/reviewed
>> qemu-ga patches posted prior to soft-freeze, along with 1 bug fix that
>> came in last week.
>>
>> This adds win32 implementations of:
>> guest-get-fsinfo
>> guest-network-get-interfaces
>>
>> and modifies guest-fstrim to return per-mount results and continue on to other
>> mounts even when a failure is encountered.
>>
>> There's also bug fixes for guest-fstrim and guest-set-time.
>>
>> The following changes since commit 7edd8e4660beb301d527257f8e04ebec0f841cb0:
>>
>> Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging (2015-07-06 14:03:44 +0100)
>>
>> are available in the git repository at:
>>
>>
>> git://github.com/mdroth/qemu.git tags/qga-pull-2015-07-06-tag
>>
>> for you to fetch changes up to d1ad92aab4a9419538b7b1b7423a8a770c7a2859:
>>
>> qga: added GuestPCIAddress information (2015-07-06 23:06:12 -0500)
>>
>> ----------------------------------------------------------------
>> tag for qga-pull-2015-07-06
> Hi. I'm afraid this doesn't build for me for Windows:
>
> /home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:21:22:
> error: ws2ipdef.h: No such file or directory
> CC qga/vss-win32.o
> CC qga/qapi-generated/qga-qapi-types.o
> /home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:25:22:
> error: ntddscsi.h: No such file or directory
> CC qga/qapi-generated/qga-qapi-visit.o
> CC qga/qapi-generated/qga-qmp-marshal.o
> cc1: warnings being treated as errors
> /home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:39:
> warning: ‘GUID_DEVINTERFACE_VOLUME’ initialized and declared ‘extern’
> /home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:101: error:
> expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘win2qemu’
> /home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:124: error:
> expected ‘)’ before ‘bus’
> AR libqemuutil.a
> /home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c: In
> function ‘get_disk_bus_type’:
> /home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:526: error:
> ‘STORAGE_PROPERTY_QUERY’ undeclared (first use in this function)
> /home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:526: error:
> (Each undeclared identifier is reported only once
> /home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:526: error:
> for each function it appears in.)
> /home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:526: error:
> expected ‘;’ before ‘query’
> /home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:527: error:
> ‘STORAGE_DEVICE_DESCRIPTOR’ undeclared (first use in this function)
> /home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:527: error:
> ‘dev_desc’ undeclared (first use in this function)
> /home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:527: error:
> ‘buf’ undeclared (first use in this function)
> /home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:527:
> warning: left-hand operand of comma expression has no effect
> /home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:532: error:
> ‘query’ undeclared (first use in this function)
> /home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:532: error:
> ‘StorageDeviceProperty’ undeclared (first use in this function)
> /home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:533: error:
> ‘PropertyStandardQuery’ undeclared (first use in this function)
> /home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:535: error:
> ‘IOCTL_STORAGE_QUERY_PROPERTY’ undeclared (first use in this function)
> /home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:543:
> warning: control reaches end of non-void function
> /home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c: In
> function ‘build_guest_disk_info’:
> /home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:552: error:
> ‘SCSI_ADDRESS’ undeclared (first use in this function)
>
>
> /home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:552: error:
> expected ‘;’ before ‘addr’
> /home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:557: error:
> ‘scsi_ad’ undeclared (first use in this function)
> /home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:557: error:
> ‘addr’ undeclared (first use in this function)
> /home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:573:
> warning: implicit declaration of function ‘find_bus_type’
> /home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:573:
> warning: nested extern declaration of ‘find_bus_type’
> /home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:574: error:
> ‘BusTypeScsi’ undeclared (first use in this function)
> /home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:574: error:
> ‘BusTypeAta’ undeclared (first use in this function)
> /home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:574: error:
> ‘BusTypeRAID’ undeclared (first use in this function)
> /home/petmay01/linaro/qemu-for-merges/qga/commands-win32.c:583: error:
> ‘IOCTL_SCSI_GET_ADDRESS’ undeclared (first use in this function)
> make: *** [qga/commands-win32.o] Error 1
>
> thanks
> -- PMM
>
To get same errors I exclude
#include <initguid.h>
#include <winioctl.h>
#include <ntddscsi.h>
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [Qemu-devel] [PULL 00/10] qemu-ga patches for 2.4.0
2015-07-07 13:25 ` Olga Krishtal
@ 2015-07-07 13:30 ` Peter Maydell
2015-07-07 17:13 ` [Qemu-devel] [PATCH] qga: fix build for older versions of mingw Olga Krishtal
0 siblings, 1 reply; 26+ messages in thread
From: Peter Maydell @ 2015-07-07 13:30 UTC (permalink / raw)
To: Olga Krishtal; +Cc: Michael Roth, QEMU Developers
On 7 July 2015 at 14:25, Olga Krishtal <okrishtal@parallels.com> wrote:
> To get same errors I exclude
> #include <initguid.h>
> #include <winioctl.h>
> #include <ntddscsi.h>
In my mingw setup the first two of these exist, but
ntddscsi.h is in ddk/.
-- PMM
^ permalink raw reply [flat|nested] 26+ messages in thread
* [Qemu-devel] [PATCH] qga: fix build for older versions of mingw
2015-07-07 13:30 ` Peter Maydell
@ 2015-07-07 17:13 ` Olga Krishtal
2015-07-07 18:06 ` Denis V. Lunev
0 siblings, 1 reply; 26+ messages in thread
From: Olga Krishtal @ 2015-07-07 17:13 UTC (permalink / raw)
Cc: peter.maydell, den, qemu-devel, Olga Krishtal
Peter, can you try this patch on your system?
In mingw older than mingw64-headers-4.0.2-1.el7.noarch
header ntddscsi.h can be found in include/ddk, however
compiler does not look there. This breaks the compilation.
The patch adds this directory in QEMU_INCLUDES.
Signed-off-by: Olga Krishtal <okrishtal@parallels.com>
---
configure | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/configure b/configure
index 52cfe18..ada8895 100755
--- a/configure
+++ b/configure
@@ -3763,7 +3763,6 @@ if test "$usb_redir" != "no" ; then
usb_redir="no"
fi
fi
-
##########################################
# check if we have VSS SDK headers for win
@@ -3820,6 +3819,14 @@ if test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$guest_agent_with_vss"
fi
##########################################
+# mingw package on Linux is quite different with different versions. ntddscsi.h
+# can be found sys-root/mingw/include and in sys-root/mingw/include/ddk
+# Add ddk directory to lookup path automatically
+if test "$mingw32" = "yes" -a "$guest_agent" != "no"; then
+ QEMU_INCLUDES="$QEMU_INCLUDES -I`$cc -print-sysroot`/mingw/include/ddk"
+fi
+
+##########################################
# Guest agent Window MSI package
if test "$guest_agent" != yes; then
--
1.8.3.1
^ permalink raw reply related [flat|nested] 26+ messages in thread
* Re: [Qemu-devel] [PATCH] qga: fix build for older versions of mingw
2015-07-07 17:13 ` [Qemu-devel] [PATCH] qga: fix build for older versions of mingw Olga Krishtal
@ 2015-07-07 18:06 ` Denis V. Lunev
2015-07-07 19:16 ` Peter Maydell
0 siblings, 1 reply; 26+ messages in thread
From: Denis V. Lunev @ 2015-07-07 18:06 UTC (permalink / raw)
To: Olga Krishtal; +Cc: peter.maydell, den, qemu-devel
On 07/07/15 20:13, Olga Krishtal wrote:
> Peter, can you try this patch on your system?
>
> In mingw older than mingw64-headers-4.0.2-1.el7.noarch
> header ntddscsi.h can be found in include/ddk, however
> compiler does not look there. This breaks the compilation.
>
> The patch adds this directory in QEMU_INCLUDES.
>
> Signed-off-by: Olga Krishtal <okrishtal@parallels.com>
> ---
> configure | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/configure b/configure
> index 52cfe18..ada8895 100755
> --- a/configure
> +++ b/configure
> @@ -3763,7 +3763,6 @@ if test "$usb_redir" != "no" ; then
> usb_redir="no"
> fi
> fi
> -
> ##########################################
> # check if we have VSS SDK headers for win
>
> @@ -3820,6 +3819,14 @@ if test "$mingw32" = "yes" -a "$guest_agent" != "no" -a "$guest_agent_with_vss"
> fi
>
> ##########################################
> +# mingw package on Linux is quite different with different versions. ntddscsi.h
> +# can be found sys-root/mingw/include and in sys-root/mingw/include/ddk
> +# Add ddk directory to lookup path automatically
> +if test "$mingw32" = "yes" -a "$guest_agent" != "no"; then
> + QEMU_INCLUDES="$QEMU_INCLUDES -I`$cc -print-sysroot`/mingw/include/ddk"
> +fi
> +
> +##########################################
> # Guest agent Window MSI package
>
> if test "$guest_agent" != yes; then
>
actually this is a dirty hack, but we want to
know whether additional include directory help or not.
If this helps, we could think how to avoid extra
configuration option and ifdef in the code.
Den
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [Qemu-devel] [PATCH] qga: fix build for older versions of mingw
2015-07-07 18:06 ` Denis V. Lunev
@ 2015-07-07 19:16 ` Peter Maydell
2015-07-07 20:02 ` Michael Roth
0 siblings, 1 reply; 26+ messages in thread
From: Peter Maydell @ 2015-07-07 19:16 UTC (permalink / raw)
To: Denis V. Lunev; +Cc: Olga Krishtal, den, QEMU Developers
On 7 July 2015 at 19:06, Denis V. Lunev <den-lists@parallels.com> wrote:
> On 07/07/15 20:13, Olga Krishtal wrote:
>>
>> Peter, can you try this patch on your system?
>>
>> In mingw older than mingw64-headers-4.0.2-1.el7.noarch
>> header ntddscsi.h can be found in include/ddk, however
>> compiler does not look there. This breaks the compilation.
>>
>> The patch adds this directory in QEMU_INCLUDES.
>>
>> Signed-off-by: Olga Krishtal <okrishtal@parallels.com>
>> ---
>> configure | 9 ++++++++-
>> 1 file changed, 8 insertions(+), 1 deletion(-)
>>
>> diff --git a/configure b/configure
>> index 52cfe18..ada8895 100755
>> --- a/configure
>> +++ b/configure
>> @@ -3763,7 +3763,6 @@ if test "$usb_redir" != "no" ; then
>> usb_redir="no"
>> fi
>> fi
>> -
>> ##########################################
>> # check if we have VSS SDK headers for win
>>
>> @@ -3820,6 +3819,14 @@ if test "$mingw32" = "yes" -a "$guest_agent" !=
>> "no" -a "$guest_agent_with_vss"
>> fi
>>
>> ##########################################
>> +# mingw package on Linux is quite different with different versions.
>> ntddscsi.h
>> +# can be found sys-root/mingw/include and in sys-root/mingw/include/ddk
>> +# Add ddk directory to lookup path automatically
>> +if test "$mingw32" = "yes" -a "$guest_agent" != "no"; then
>> + QEMU_INCLUDES="$QEMU_INCLUDES -I`$cc -print-sysroot`/mingw/include/ddk"
>> +fi
>> +
>> +##########################################
>> # Guest agent Window MSI package
>>
>> if test "$guest_agent" != yes; then
>>
>
> actually this is a dirty hack, but we want to
> know whether additional include directory help or not.
> If this helps, we could think how to avoid extra
> configuration option and ifdef in the code.
I agree it's a pretty nasty hack :-)
Unfortunately my build machine is going to be running
flat out processing all the last-minute pull requests.
I won't be able to test this until tomorrow at best.
-- PMM
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [Qemu-devel] [PATCH] qga: fix build for older versions of mingw
2015-07-07 19:16 ` Peter Maydell
@ 2015-07-07 20:02 ` Michael Roth
2015-07-07 20:04 ` Denis V. Lunev
0 siblings, 1 reply; 26+ messages in thread
From: Michael Roth @ 2015-07-07 20:02 UTC (permalink / raw)
To: Peter Maydell, Denis V. Lunev; +Cc: Olga Krishtal, den, QEMU Developers
Quoting Peter Maydell (2015-07-07 14:16:29)
> On 7 July 2015 at 19:06, Denis V. Lunev <den-lists@parallels.com> wrote:
> > On 07/07/15 20:13, Olga Krishtal wrote:
> >>
> >> Peter, can you try this patch on your system?
> >>
> >> In mingw older than mingw64-headers-4.0.2-1.el7.noarch
> >> header ntddscsi.h can be found in include/ddk, however
> >> compiler does not look there. This breaks the compilation.
> >>
> >> The patch adds this directory in QEMU_INCLUDES.
> >>
> >> Signed-off-by: Olga Krishtal <okrishtal@parallels.com>
> >> ---
> >> configure | 9 ++++++++-
> >> 1 file changed, 8 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/configure b/configure
> >> index 52cfe18..ada8895 100755
> >> --- a/configure
> >> +++ b/configure
> >> @@ -3763,7 +3763,6 @@ if test "$usb_redir" != "no" ; then
> >> usb_redir="no"
> >> fi
> >> fi
> >> -
> >> ##########################################
> >> # check if we have VSS SDK headers for win
> >>
> >> @@ -3820,6 +3819,14 @@ if test "$mingw32" = "yes" -a "$guest_agent" !=
> >> "no" -a "$guest_agent_with_vss"
> >> fi
> >>
> >> ##########################################
> >> +# mingw package on Linux is quite different with different versions.
> >> ntddscsi.h
> >> +# can be found sys-root/mingw/include and in sys-root/mingw/include/ddk
> >> +# Add ddk directory to lookup path automatically
> >> +if test "$mingw32" = "yes" -a "$guest_agent" != "no"; then
> >> + QEMU_INCLUDES="$QEMU_INCLUDES -I`$cc -print-sysroot`/mingw/include/ddk"
> >> +fi
> >> +
> >> +##########################################
> >> # Guest agent Window MSI package
> >>
> >> if test "$guest_agent" != yes; then
> >>
> >
> > actually this is a dirty hack, but we want to
> > know whether additional include directory help or not.
> > If this helps, we could think how to avoid extra
> > configuration option and ifdef in the code.
>
> I agree it's a pretty nasty hack :-)
>
> Unfortunately my build machine is going to be running
> flat out processing all the last-minute pull requests.
> I won't be able to test this until tomorrow at best.
I've gotten an ubuntu 14.04 mingw environment set up that I think matches yours
fairly closely, so I can give any proposed fixes a spin.
Unfortunately simply pointing to ddk/ntddscsi.h instead of ntddscsi.h
doesn't quite do it:
In file included from /usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/include/ddk/ntddk.h:76,
from /usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/include/ddk/ntddscsi.h:34,
from /home/mdroth/w/qemu4.git/qga/commands-win32.c:25:
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/include/ddk/winddk.h:1069: error: redefinition of ‘struct _DRIVE_LAYOUT_INFORMATION_MBR’
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/include/ddk/winddk.h:1073: error: redefinition of ‘struct _DRIVE_LAYOUT_INFORMATION_GPT’
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/include/ddk/winddk.h:1080: error: redefinition of ‘struct _PARTITION_INFORMATION_MBR’
In file included from /usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/include/ddk/ntddk.h:76,
from /usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/include/ddk/ntddscsi.h:34,
from /home/mdroth/w/qemu4.git/qga/commands-win32.c:25:
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/include/ddk/winddk.h:3575: error: nested redefinition of ‘enum _PARTITION_STYLE’
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/include/ddk/winddk.h:3575: error: redeclaration of ‘enum _PARTITION_STYLE’
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/include/ddk/winddk.h:3576: error: redeclaration of enumerator ‘PARTITION_STYLE_MBR’
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/include/winioctl.h:208: error: previous definition of ‘PARTITION_STYLE_MBR’ was here
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/include/ddk/winddk.h:3578: error: redeclaration of enumerator ‘PARTITION_STYLE_GPT’
/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/include/winioctl.h:209: error: previous definition of ‘PARTITION_STYLE_GPT’ was here
...
I'm still trying to make sense of how the headers are organized but the
impression I'm getting is that stuff in ddk/ is meant for kernel code and
doesn't play very nicely with userspace headers. At some point ntddscsi.h
got moved out of ddk/ and #ifdef guards were added all over the place to
make it useable, so it seems likely we'll have to disable the feature
completely for the ddk/ntddscsi.h versions of mingw.
>
> -- PMM
>
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [Qemu-devel] [PATCH] qga: fix build for older versions of mingw
2015-07-07 20:02 ` Michael Roth
@ 2015-07-07 20:04 ` Denis V. Lunev
2015-07-07 21:23 ` Michael Roth
0 siblings, 1 reply; 26+ messages in thread
From: Denis V. Lunev @ 2015-07-07 20:04 UTC (permalink / raw)
To: Michael Roth, Peter Maydell; +Cc: Olga Krishtal, den, QEMU Developers
On 07/07/15 23:02, Michael Roth wrote:
> Quoting Peter Maydell (2015-07-07 14:16:29)
>> On 7 July 2015 at 19:06, Denis V. Lunev <den-lists@parallels.com> wrote:
>>> On 07/07/15 20:13, Olga Krishtal wrote:
>>>>
>>>> Peter, can you try this patch on your system?
>>>>
>>>> In mingw older than mingw64-headers-4.0.2-1.el7.noarch
>>>> header ntddscsi.h can be found in include/ddk, however
>>>> compiler does not look there. This breaks the compilation.
>>>>
>>>> The patch adds this directory in QEMU_INCLUDES.
>>>>
>>>> Signed-off-by: Olga Krishtal <okrishtal@parallels.com>
>>>> ---
>>>> configure | 9 ++++++++-
>>>> 1 file changed, 8 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/configure b/configure
>>>> index 52cfe18..ada8895 100755
>>>> --- a/configure
>>>> +++ b/configure
>>>> @@ -3763,7 +3763,6 @@ if test "$usb_redir" != "no" ; then
>>>> usb_redir="no"
>>>> fi
>>>> fi
>>>> -
>>>> ##########################################
>>>> # check if we have VSS SDK headers for win
>>>>
>>>> @@ -3820,6 +3819,14 @@ if test "$mingw32" = "yes" -a "$guest_agent" !=
>>>> "no" -a "$guest_agent_with_vss"
>>>> fi
>>>>
>>>> ##########################################
>>>> +# mingw package on Linux is quite different with different versions.
>>>> ntddscsi.h
>>>> +# can be found sys-root/mingw/include and in sys-root/mingw/include/ddk
>>>> +# Add ddk directory to lookup path automatically
>>>> +if test "$mingw32" = "yes" -a "$guest_agent" != "no"; then
>>>> + QEMU_INCLUDES="$QEMU_INCLUDES -I`$cc -print-sysroot`/mingw/include/ddk"
>>>> +fi
>>>> +
>>>> +##########################################
>>>> # Guest agent Window MSI package
>>>>
>>>> if test "$guest_agent" != yes; then
>>>>
>>>
>>> actually this is a dirty hack, but we want to
>>> know whether additional include directory help or not.
>>> If this helps, we could think how to avoid extra
>>> configuration option and ifdef in the code.
>>
>> I agree it's a pretty nasty hack :-)
>>
>> Unfortunately my build machine is going to be running
>> flat out processing all the last-minute pull requests.
>> I won't be able to test this until tomorrow at best.
>
> I've gotten an ubuntu 14.04 mingw environment set up that I think matches yours
> fairly closely, so I can give any proposed fixes a spin.
>
> Unfortunately simply pointing to ddk/ntddscsi.h instead of ntddscsi.h
> doesn't quite do it:
>
> In file included from /usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/include/ddk/ntddk.h:76,
> from /usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/include/ddk/ntddscsi.h:34,
> from /home/mdroth/w/qemu4.git/qga/commands-win32.c:25:
> /usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/include/ddk/winddk.h:1069: error: redefinition of ‘struct _DRIVE_LAYOUT_INFORMATION_MBR’
> /usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/include/ddk/winddk.h:1073: error: redefinition of ‘struct _DRIVE_LAYOUT_INFORMATION_GPT’
> /usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/include/ddk/winddk.h:1080: error: redefinition of ‘struct _PARTITION_INFORMATION_MBR’
> In file included from /usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/include/ddk/ntddk.h:76,
> from /usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/include/ddk/ntddscsi.h:34,
> from /home/mdroth/w/qemu4.git/qga/commands-win32.c:25:
> /usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/include/ddk/winddk.h:3575: error: nested redefinition of ‘enum _PARTITION_STYLE’
> /usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/include/ddk/winddk.h:3575: error: redeclaration of ‘enum _PARTITION_STYLE’
> /usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/include/ddk/winddk.h:3576: error: redeclaration of enumerator ‘PARTITION_STYLE_MBR’
> /usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/include/winioctl.h:208: error: previous definition of ‘PARTITION_STYLE_MBR’ was here
> /usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/include/ddk/winddk.h:3578: error: redeclaration of enumerator ‘PARTITION_STYLE_GPT’
> /usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/include/winioctl.h:209: error: previous definition of ‘PARTITION_STYLE_GPT’ was here
> ...
>
> I'm still trying to make sense of how the headers are organized but the
> impression I'm getting is that stuff in ddk/ is meant for kernel code and
> doesn't play very nicely with userspace headers. At some point ntddscsi.h
> got moved out of ddk/ and #ifdef guards were added all over the place to
> make it useable, so it seems likely we'll have to disable the feature
> completely for the ddk/ntddscsi.h versions of mingw.
>
>>
>> -- PMM
>>
>
yep :( this seems so thus we need to disable it if the header is not
available
^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [Qemu-devel] [PATCH] qga: fix build for older versions of mingw
2015-07-07 20:04 ` Denis V. Lunev
@ 2015-07-07 21:23 ` Michael Roth
2015-07-07 21:28 ` Peter Maydell
0 siblings, 1 reply; 26+ messages in thread
From: Michael Roth @ 2015-07-07 21:23 UTC (permalink / raw)
To: Denis V. Lunev, Peter Maydell; +Cc: Olga Krishtal, den, QEMU Developers
Quoting Denis V. Lunev (2015-07-07 15:04:20)
> On 07/07/15 23:02, Michael Roth wrote:
> > Quoting Peter Maydell (2015-07-07 14:16:29)
> >> On 7 July 2015 at 19:06, Denis V. Lunev <den-lists@parallels.com> wrote:
> >>> On 07/07/15 20:13, Olga Krishtal wrote:
> >>>>
> >>>> Peter, can you try this patch on your system?
> >>>>
> >>>> In mingw older than mingw64-headers-4.0.2-1.el7.noarch
> >>>> header ntddscsi.h can be found in include/ddk, however
> >>>> compiler does not look there. This breaks the compilation.
> >>>>
> >>>> The patch adds this directory in QEMU_INCLUDES.
> >>>>
> >>>> Signed-off-by: Olga Krishtal <okrishtal@parallels.com>
> >>>> ---
> >>>> configure | 9 ++++++++-
> >>>> 1 file changed, 8 insertions(+), 1 deletion(-)
> >>>>
> >>>> diff --git a/configure b/configure
> >>>> index 52cfe18..ada8895 100755
> >>>> --- a/configure
> >>>> +++ b/configure
> >>>> @@ -3763,7 +3763,6 @@ if test "$usb_redir" != "no" ; then
> >>>> usb_redir="no"
> >>>> fi
> >>>> fi
> >>>> -
> >>>> ##########################################
> >>>> # check if we have VSS SDK headers for win
> >>>>
> >>>> @@ -3820,6 +3819,14 @@ if test "$mingw32" = "yes" -a "$guest_agent" !=
> >>>> "no" -a "$guest_agent_with_vss"
> >>>> fi
> >>>>
> >>>> ##########################################
> >>>> +# mingw package on Linux is quite different with different versions.
> >>>> ntddscsi.h
> >>>> +# can be found sys-root/mingw/include and in sys-root/mingw/include/ddk
> >>>> +# Add ddk directory to lookup path automatically
> >>>> +if test "$mingw32" = "yes" -a "$guest_agent" != "no"; then
> >>>> + QEMU_INCLUDES="$QEMU_INCLUDES -I`$cc -print-sysroot`/mingw/include/ddk"
> >>>> +fi
> >>>> +
> >>>> +##########################################
> >>>> # Guest agent Window MSI package
> >>>>
> >>>> if test "$guest_agent" != yes; then
> >>>>
> >>>
> >>> actually this is a dirty hack, but we want to
> >>> know whether additional include directory help or not.
> >>> If this helps, we could think how to avoid extra
> >>> configuration option and ifdef in the code.
> >>
> >> I agree it's a pretty nasty hack :-)
> >>
> >> Unfortunately my build machine is going to be running
> >> flat out processing all the last-minute pull requests.
> >> I won't be able to test this until tomorrow at best.
> >
> > I've gotten an ubuntu 14.04 mingw environment set up that I think matches yours
> > fairly closely, so I can give any proposed fixes a spin.
> >
> > Unfortunately simply pointing to ddk/ntddscsi.h instead of ntddscsi.h
> > doesn't quite do it:
> >
> > In file included from /usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/include/ddk/ntddk.h:76,
> > from /usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/include/ddk/ntddscsi.h:34,
> > from /home/mdroth/w/qemu4.git/qga/commands-win32.c:25:
> > /usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/include/ddk/winddk.h:1069: error: redefinition of ‘struct _DRIVE_LAYOUT_INFORMATION_MBR’
> > /usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/include/ddk/winddk.h:1073: error: redefinition of ‘struct _DRIVE_LAYOUT_INFORMATION_GPT’
> > /usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/include/ddk/winddk.h:1080: error: redefinition of ‘struct _PARTITION_INFORMATION_MBR’
> > In file included from /usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/include/ddk/ntddk.h:76,
> > from /usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/include/ddk/ntddscsi.h:34,
> > from /home/mdroth/w/qemu4.git/qga/commands-win32.c:25:
> > /usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/include/ddk/winddk.h:3575: error: nested redefinition of ‘enum _PARTITION_STYLE’
> > /usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/include/ddk/winddk.h:3575: error: redeclaration of ‘enum _PARTITION_STYLE’
> > /usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/include/ddk/winddk.h:3576: error: redeclaration of enumerator ‘PARTITION_STYLE_MBR’
> > /usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/include/winioctl.h:208: error: previous definition of ‘PARTITION_STYLE_MBR’ was here
> > /usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/include/ddk/winddk.h:3578: error: redeclaration of enumerator ‘PARTITION_STYLE_GPT’
> > /usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/include/winioctl.h:209: error: previous definition of ‘PARTITION_STYLE_GPT’ was here
> > ...
> >
> > I'm still trying to make sense of how the headers are organized but the
> > impression I'm getting is that stuff in ddk/ is meant for kernel code and
> > doesn't play very nicely with userspace headers. At some point ntddscsi.h
> > got moved out of ddk/ and #ifdef guards were added all over the place to
> > make it useable, so it seems likely we'll have to disable the feature
> > completely for the ddk/ntddscsi.h versions of mingw.
> >
> >>
> >> -- PMM
> >>
> >
>
>
> yep :( this seems so thus we need to disable it if the header is not
> available
Hmm, well it seems it's *almost* possible. I can build with the
following changes (ddk/ntddstor.h replaces winioctl.h):
diff --git a/qga/commands-win32.c b/qga/commands-win32.c
index 609f3c7..6ebb531 100644
--- a/qga/commands-win32.c
+++ b/qga/commands-win32.c
@@ -21,8 +21,11 @@
#include <ws2ipdef.h>
#include <iptypes.h>
#include <iphlpapi.h>
-#include <winioctl.h>
-#include <ntddscsi.h>
+#include <ddk/ntddk.h>
+#include <ddk/ntddscsi.h>
+#include <ddk/ntddstor.h>
#include <setupapi.h>
#include <initguid.h>
#include "qga/guest-agent-core.h"
But I have to modify ddk/winddk.h (pulled in by ddk/ntddk.h) due to an
unfortunately-named 'PCIBus' enum that conflicts with QEMU defs. I
don't think there's a reasonable way to work around this so we'll
have to stick to the original plan.
Since I have a build environment handy I'll go ahead and put together
a patch to disable the feature via a configure check/flag.
>
^ permalink raw reply related [flat|nested] 26+ messages in thread
* Re: [Qemu-devel] [PATCH] qga: fix build for older versions of mingw
2015-07-07 21:23 ` Michael Roth
@ 2015-07-07 21:28 ` Peter Maydell
0 siblings, 0 replies; 26+ messages in thread
From: Peter Maydell @ 2015-07-07 21:28 UTC (permalink / raw)
To: Michael Roth; +Cc: Olga Krishtal, den, QEMU Developers, Denis V. Lunev
On 7 July 2015 at 22:23, Michael Roth <mdroth@linux.vnet.ibm.com> wrote:
> Since I have a build environment handy I'll go ahead and put together
> a patch to disable the feature via a configure check/flag.
Thanks. Since this is a pretty old build environment I
think it's reasonable to just disable the feature there.
-- PMM
^ permalink raw reply [flat|nested] 26+ messages in thread