qga-pull-2022-12-20

-----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEwsLBCepDxjwUI+uE711egWG6hOcFAmOhv2cACgkQ711egWG6
 hOfS0Q/+Jf4hMz5leOt2OBSqEev4dlX+AD2kMOvLmUn8+wKK126bZ+oZpkm+C94e
 MahSSb9xdIpM3WVKSO7kWyCu1i/gFRRbkRPwT6ULc3dAy9LOrrQUWEbgRi0t5/+2
 sx/o7kdc5+8j5Y1qhs4hJfmcO3OmuzDzSD/U3qMPV4HWyAvs4urlsdg3s1cq8Sh2
 YfpfmzS1WqVNHORRIMfwY0mXLdFmDLhvIDCC6KjBcmm6F+5Yb/CWNUkdDyfQthYL
 adRrcs791a9zj0bQwW4iQj5wDlsfCxVFCao2E0IzXmaz+FgtFu2omCw+OTum5Gum
 u0VSd71HL1Z6au0Fr55MZjpFPTOvZNXDwDWhR+4lLR3+yRJGFFCE03Kn0OnPAKwW
 17r804vFo95V7h4CcoUlwvhP5HiHKk+4seW/hdkXj83SjT8kJMr2HwVM3/br/1lI
 wYTOZXVcLkCDYX5HufsBlcySPxU4yVwD8KWFh1K/eJmLlVQ785fmjvkX3fLSL36f
 U0uWfKSwy/ud3iS33uhGnvlI5t/Muop83UkxZkaxtDcoGH1c91VsDWwc29ivyzxg
 yR0TGvrxGZ0zb3sNIJ9ypd+eP5HwM7ukxtet59nkVvOsuWT+x0+ThqxAvI8lz9d9
 cJOlLIB8GjeI4+1zPGOxa9NyrfFVhSncxKjcPxZQE+OlwhDKhlo=
 =dV+e
 -----END PGP SIGNATURE-----

Merge tag 'qga-pull-2022-12-20' of github.com:kostyanf14/qemu into staging

qga-pull-2022-12-20

# gpg: Signature made Tue 20 Dec 2022 13:57:59 GMT
# gpg:                using RSA key C2C2C109EA43C63C1423EB84EF5D5E8161BA84E7
# gpg: Good signature from "Kostiantyn Kostiuk (Upstream PR sign) <kkostiuk@redhat.com>" [unknown]
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: C2C2 C109 EA43 C63C 1423  EB84 EF5D 5E81 61BA 84E7

* tag 'qga-pull-2022-12-20' of github.com:kostyanf14/qemu:
  qga-win: choose the right libpcre version to include in MSI package
  qga: map GLib log levels to system levels
  qga-win: add logging to Windows event log
  qga: Add initial OpenBSD and NetBSD support
  qga:/qga-win: skip getting pci info for USB disks
  qga:/qga-win: adding a empty PCI address creation function

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2022-12-20 21:35:09 +00:00
commit 67de3d090d
9 changed files with 133 additions and 25 deletions

3
configure vendored
View File

@ -372,6 +372,7 @@ smbd="$SMBD"
strip="${STRIP-${cross_prefix}strip}"
widl="${WIDL-${cross_prefix}widl}"
windres="${WINDRES-${cross_prefix}windres}"
windmc="${WINDMC-${cross_prefix}windmc}"
pkg_config_exe="${PKG_CONFIG-${cross_prefix}pkg-config}"
query_pkg_config() {
"${pkg_config_exe}" ${QEMU_PKG_CONFIG_FLAGS} "$@"
@ -2561,6 +2562,7 @@ if test "$skip_meson" = no; then
echo "strip = [$(meson_quote $strip)]" >> $cross
echo "widl = [$(meson_quote $widl)]" >> $cross
echo "windres = [$(meson_quote $windres)]" >> $cross
echo "windmc = [$(meson_quote $windmc)]" >> $cross
if test "$cross_compile" = "yes"; then
cross_arg="--cross-file config-meson.cross"
echo "[host_machine]" >> $cross
@ -2667,6 +2669,7 @@ preserve_env SMBD
preserve_env STRIP
preserve_env WIDL
preserve_env WINDRES
preserve_env WINDMC
printf "exec" >>config.status
for i in "$0" "$@"; do

View File

@ -75,7 +75,7 @@ have_tools = get_option('tools') \
.allowed()
have_ga = get_option('guest_agent') \
.disable_auto_if(not have_system and not have_tools) \
.require(targetos in ['sunos', 'linux', 'windows', 'freebsd'],
.require(targetos in ['sunos', 'linux', 'windows', 'freebsd', 'netbsd', 'openbsd'],
error_message: 'unsupported OS for QEMU guest agent') \
.allowed()
have_block = have_system or have_tools

View File

@ -21,7 +21,12 @@
#include <sys/ucred.h>
#include <sys/mount.h>
#include <net/if_dl.h>
#if defined(__NetBSD__) || defined(__OpenBSD__)
#include <net/if_arp.h>
#include <netinet/if_ether.h>
#else
#include <net/ethernet.h>
#endif
#include <paths.h>
#if defined(CONFIG_FSFREEZE) || defined(CONFIG_FSTRIM)

View File

@ -45,7 +45,12 @@
#include <arpa/inet.h>
#include <sys/socket.h>
#include <net/if.h>
#if defined(__NetBSD__) || defined(__OpenBSD__)
#include <net/if_arp.h>
#include <netinet/if_ether.h>
#else
#include <net/ethernet.h>
#endif
#include <sys/types.h>
#ifdef CONFIG_SOLARIS
#include <sys/sockio.h>
@ -2872,7 +2877,7 @@ static int guest_get_network_stats(const char *name,
return -1;
}
#ifndef __FreeBSD__
#ifndef CONFIG_BSD
/*
* Fill "buf" with MAC address by ifaddrs. Pointer buf must point to a
* buffer with ETHER_ADDR_LEN length at least.
@ -2921,7 +2926,7 @@ bool guest_get_hw_addr(struct ifaddrs *ifa, unsigned char *buf,
close(sock);
return true;
}
#endif /* __FreeBSD__ */
#endif /* CONFIG_BSD */
/*
* Build information about guest interfaces

View File

@ -596,6 +596,18 @@ static void get_pci_address_for_device(GuestPCIAddress *pci,
}
}
static GuestPCIAddress *get_empty_pci_address(void)
{
GuestPCIAddress *pci = NULL;
pci = g_malloc0(sizeof(*pci));
pci->domain = -1;
pci->slot = -1;
pci->function = -1;
pci->bus = -1;
return pci;
}
static GuestPCIAddress *get_pci_info(int number, Error **errp)
{
HDEVINFO dev_info = INVALID_HANDLE_VALUE;
@ -605,13 +617,7 @@ static GuestPCIAddress *get_pci_info(int number, Error **errp)
SP_DEVICE_INTERFACE_DATA dev_iface_data;
HANDLE dev_file;
int i;
GuestPCIAddress *pci = NULL;
pci = g_malloc0(sizeof(*pci));
pci->domain = -1;
pci->slot = -1;
pci->function = -1;
pci->bus = -1;
GuestPCIAddress *pci = get_empty_pci_address();
dev_info = SetupDiGetClassDevs(&GUID_DEVINTERFACE_DISK, 0, 0,
DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
@ -868,10 +874,14 @@ static void get_single_disk_info(int disk_number,
* if that doesn't hold since that suggests some other unexpected
* breakage
*/
disk->pci_controller = get_pci_info(disk_number, &local_err);
if (local_err) {
error_propagate(errp, local_err);
goto err_close;
if (disk->bus_type == GUEST_DISK_BUS_TYPE_USB) {
disk->pci_controller = get_empty_pci_address();
} else {
disk->pci_controller = get_pci_info(disk_number, &local_err);
if (local_err) {
error_propagate(errp, local_err);
goto err_close;
}
}
if (disk->bus_type == GUEST_DISK_BUS_TYPE_SCSI
|| disk->bus_type == GUEST_DISK_BUS_TYPE_IDE

View File

@ -101,15 +101,26 @@
<Component Id="libwinpthread" Guid="{6C117C78-0F47-4B07-8F34-6BEE11643829}">
<File Id="libwinpthread_1.dll" Name="libwinpthread-1.dll" Source="$(var.BIN_DIR)/libwinpthread-1.dll" KeyPath="yes" DiskId="1"/>
</Component>
<Component Id="libpcre" Guid="{7A86B45E-A009-489A-A849-CE3BACF03CD0}">
<File Id="libpcre_1.dll" Name="libpcre-1.dll" Source="$(var.BIN_DIR)/libpcre-1.dll" KeyPath="yes" DiskId="1"/>
</Component>
<?if $(var.LIBPCRE) = "libpcre1"?>
<Component Id="libpcre" Guid="{7A86B45E-A009-489A-A849-CE3BACF03CD0}">
<File Id="libpcre_1.dll" Name="libpcre-1.dll" Source="$(var.BIN_DIR)/libpcre-1.dll" KeyPath="yes" DiskId="1"/>
</Component>
<?else?>
<Component Id="libpcre" Guid="{F92A3804-B59C-419D-8F29-99A30352C156}">
<File Id="libpcre2_8_0.dll" Name="libpcre2-8-0.dll" Source="$(var.BIN_DIR)/libpcre2-8-0.dll" KeyPath="yes" DiskId="1"/>
</Component>
<?endif?>
<Component Id="registry_entries" Guid="{D075D109-51CA-11E3-9F8B-000C29858960}">
<RegistryKey Root="HKLM"
Key="Software\$(var.QEMU_GA_MANUFACTURER)\$(var.QEMU_GA_DISTRO)\Tools\QemuGA">
<RegistryValue Type="string" Name="ProductID" Value="fb0a0d66-c7fb-4e2e-a16b-c4a3bfe8d13b" />
<RegistryValue Type="string" Name="Version" Value="$(var.QEMU_GA_VERSION)" />
</RegistryKey>
<RegistryKey Root="HKLM"
Key="System\CurrentControlSet\Services\EventLog\Application\qemu-ga">
<RegistryValue Type="integer" Name="TypesSupported" Value="7" />
<RegistryValue Type="string" Name="EventMessageFile" Value="[qemu_ga_directory]qemu-ga.exe" />
</RegistryKey>
</Component>
</Directory>
</Directory>

View File

@ -40,11 +40,11 @@
#include "commands-common.h"
#ifndef _WIN32
#ifdef __FreeBSD__
#ifdef CONFIG_BSD
#define QGA_VIRTIO_PATH_DEFAULT "/dev/vtcon/org.qemu.guest_agent.0"
#else /* __FreeBSD__ */
#else /* CONFIG_BSD */
#define QGA_VIRTIO_PATH_DEFAULT "/dev/virtio-ports/org.qemu.guest_agent.0"
#endif /* __FreeBSD__ */
#endif /* CONFIG_BSD */
#define QGA_SERIAL_PATH_DEFAULT "/dev/ttyS0"
#define QGA_STATE_RELATIVE_DIR "run"
#else
@ -83,6 +83,7 @@ struct GAState {
#ifdef _WIN32
GAService service;
HANDLE wakeup_event;
HANDLE event_log;
#endif
bool delimit_response;
bool frozen;
@ -313,6 +314,38 @@ void ga_enable_logging(GAState *s)
s->logging_enabled = true;
}
static int glib_log_level_to_system(int level)
{
switch (level) {
#ifndef _WIN32
case G_LOG_LEVEL_ERROR:
return LOG_ERR;
case G_LOG_LEVEL_CRITICAL:
return LOG_CRIT;
case G_LOG_LEVEL_WARNING:
return LOG_WARNING;
case G_LOG_LEVEL_MESSAGE:
return LOG_NOTICE;
case G_LOG_LEVEL_DEBUG:
return LOG_DEBUG;
case G_LOG_LEVEL_INFO:
default:
return LOG_INFO;
#else
case G_LOG_LEVEL_ERROR:
case G_LOG_LEVEL_CRITICAL:
return EVENTLOG_ERROR_TYPE;
case G_LOG_LEVEL_WARNING:
return EVENTLOG_WARNING_TYPE;
case G_LOG_LEVEL_MESSAGE:
case G_LOG_LEVEL_INFO:
case G_LOG_LEVEL_DEBUG:
default:
return EVENTLOG_INFORMATION_TYPE;
#endif
}
}
static void ga_log(const gchar *domain, GLogLevelFlags level,
const gchar *msg, gpointer opaque)
{
@ -324,13 +357,14 @@ static void ga_log(const gchar *domain, GLogLevelFlags level,
}
level &= G_LOG_LEVEL_MASK;
#ifndef _WIN32
if (g_strcmp0(domain, "syslog") == 0) {
syslog(LOG_INFO, "%s: %s", level_str, msg);
} else if (level & s->log_level) {
#ifndef _WIN32
syslog(glib_log_level_to_system(level), "%s: %s", level_str, msg);
#else
if (level & s->log_level) {
ReportEvent(s->event_log, glib_log_level_to_system(level),
0, 1, NULL, 1, 0, &msg, NULL);
#endif
} else if (level & s->log_level) {
g_autoptr(GDateTime) now = g_date_time_new_now_utc();
g_autofree char *nowstr = g_date_time_format(now, "%s.%f");
fprintf(s->log_file, "%s: %s: %s\n", nowstr, level_str, msg);
@ -1286,6 +1320,13 @@ static GAState *initialize_agent(GAConfig *config, int socket_activation)
g_debug("Guest agent version %s started", QEMU_FULL_VERSION);
#ifdef _WIN32
s->event_log = RegisterEventSource(NULL, "qemu-ga");
if (!s->event_log) {
g_autofree gchar *errmsg = g_win32_error_message(GetLastError());
g_critical("unable to register event source: %s", errmsg);
return NULL;
}
/* On win32 the state directory is application specific (be it the default
* or a user override). We got past the command line parsing; let's create
* the directory (with any intermediate directories). If we run into an
@ -1377,6 +1418,7 @@ static void cleanup_agent(GAState *s)
{
#ifdef _WIN32
CloseHandle(s->wakeup_event);
CloseHandle(s->event_log);
#endif
if (s->command_state) {
ga_command_state_cleanup_all(s->command_state);

View File

@ -98,7 +98,24 @@ if targetos == 'windows'
endif
endif
qga = executable('qemu-ga', qga_ss.sources(),
qga_objs = []
if targetos == 'windows'
windmc = find_program('windmc', required: true)
windres = find_program('windres', required: true)
msgrc = custom_target('messages-win32.rc',
input: 'messages-win32.mc',
output: ['messages-win32.rc', 'MSG00409.bin', 'messages-win32.h'],
command: [windmc, '-h', '@OUTDIR@', '-r', '@OUTDIR@', '@INPUT@'])
msgobj = custom_target('messages-win32.o',
input: msgrc[0],
output: 'messages-win32.o',
command: [windres, '-I', '@OUTDIR@', '-o', '@OUTPUT@', '@INPUT@'])
qga_objs = [msgobj]
endif
qga = executable('qemu-ga', qga_ss.sources() + qga_objs,
link_args: qga_libs,
dependencies: [qemuutil, libudev],
install: true)
@ -123,6 +140,11 @@ if targetos == 'windows'
qemu_ga_msi_vss = ['-D', 'InstallVss']
deps += qga_vss
endif
if glib.version() < '2.73.2'
libpcre = 'libpcre1'
else
libpcre = 'libpcre2'
endif
qga_msi = custom_target('QGA MSI',
input: files('installer/qemu-ga.wxs'),
output: 'qemu-ga-@0@.msi'.format(host_arch),
@ -136,6 +158,7 @@ if targetos == 'windows'
'-D', 'QEMU_GA_VERSION=' + config_host['QEMU_GA_VERSION'],
'-D', 'QEMU_GA_MANUFACTURER=' + config_host['QEMU_GA_MANUFACTURER'],
'-D', 'QEMU_GA_DISTRO=' + config_host['QEMU_GA_DISTRO'],
'-D', 'LIBPCRE=' + libpcre,
])
all_qga += [qga_msi]
alias_target('msi', qga_msi)

9
qga/messages-win32.mc Normal file
View File

@ -0,0 +1,9 @@
LanguageNames=(
English=0x409:MSG00409
)
MessageId=1
SymbolicName=QEMU_GA_EVENTLOG_GENERAL
Language=English
%1
.