[PATCH] Add qemu_vga.ndrv to build/pc-bios folder

2021-08-31 Thread John Arbuckle
Currently the file qemu_vga.ndrv is not copied into the /build/pc-bios folder. 
This makes all video resolution choices disappear from a PowerPC Mac OS guest. 
This patch has the qemu_vga.ndrv file copied into the build/pc-bios folder 
giving users back their video resolution choices.

Signed-off-by: John Arbuckle 
---
 configure | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index 9a79a004d7..281577e46f 100755
--- a/configure
+++ b/configure
@@ -5056,7 +5056,9 @@ for bios_file in \
 $source_path/pc-bios/openbios-* \
 $source_path/pc-bios/u-boot.* \
 $source_path/pc-bios/edk2-*.fd.bz2 \
-$source_path/pc-bios/palcode-*
+$source_path/pc-bios/palcode-* \
+$source_path/pc-bios/qemu_vga.ndrv
+
 do
 LINKS="$LINKS pc-bios/$(basename $bios_file)"
 done
-- 
2.24.3 (Apple Git-128)




[PATCH v2] Report any problems with loading the VGA driver for Macintosh targets

2021-08-30 Thread John Arbuckle
I was having a problem with missing video resolutions in my Mac OS 9 VM. When I
ran QEMU it gave no indication as to why these resolutions were missing. I found
out that the OpenFirmware VGA driver was not being loaded. To prevent anyone 
from
going thru the same trouble I went thru I added messages that the user can see
when a problem takes place with loading this driver in the future.

Signed-off-by: John Arbuckle 
---
v2 changes:
- Replaced printf() with warn_report().
- Removed newline characters from messages.

 hw/ppc/mac_newworld.c | 6 ++
 hw/ppc/mac_oldworld.c | 6 ++
 2 files changed, 12 insertions(+)

diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c
index 7bb7ac3997..19a142cfe5 100644
--- a/hw/ppc/mac_newworld.c
+++ b/hw/ppc/mac_newworld.c
@@ -526,8 +526,14 @@ static void ppc_core99_init(MachineState *machine)
 
 if (g_file_get_contents(filename, _file, _size, NULL)) {
 fw_cfg_add_file(fw_cfg, "ndrv/qemu_vga.ndrv", ndrv_file, 
ndrv_size);
+} else {
+warn_report("failed to load driver %s. This may cause video"
+" problems.", NDRV_VGA_FILENAME);
 }
 g_free(filename);
+} else {
+warn_report("driver %s not found. This may cause video problems.",
+NDRV_VGA_FILENAME);
 }
 
 qemu_register_boot_set(fw_cfg_boot_set, fw_cfg);
diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c
index de2be960e6..041ccebe25 100644
--- a/hw/ppc/mac_oldworld.c
+++ b/hw/ppc/mac_oldworld.c
@@ -367,8 +367,14 @@ static void ppc_heathrow_init(MachineState *machine)
 
 if (g_file_get_contents(filename, _file, _size, NULL)) {
 fw_cfg_add_file(fw_cfg, "ndrv/qemu_vga.ndrv", ndrv_file, 
ndrv_size);
+} else {
+warn_report("failed to load driver %s. This may cause video "
+"problems.", NDRV_VGA_FILENAME);
 }
 g_free(filename);
+} else {
+warn_report("driver %s not found. This may cause video problems.",
+NDRV_VGA_FILENAME);
 }
 
 qemu_register_boot_set(fw_cfg_boot_set, fw_cfg);
-- 
2.24.3 (Apple Git-128)




[PATCH] Report any problems with loading the VGA driver for PPC Macintosh targets

2021-08-27 Thread John Arbuckle
I was having a problem with missing video resolutions in my Mac OS 9 VM. When I
ran QEMU it gave no indication as to why these resolutions were missing. I found
out that the OpenFirmware VGA driver was not being loaded. To prevent anyone 
from
going thru the same trouble I went thru I added messages that the user can see
when a problem takes place with loading this driver in the future.

Signed-off-by: John Arbuckle 
---
 hw/ppc/mac_newworld.c | 6 ++
 hw/ppc/mac_oldworld.c | 6 ++
 2 files changed, 12 insertions(+)

diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c
index 7bb7ac3997..c1960452b8 100644
--- a/hw/ppc/mac_newworld.c
+++ b/hw/ppc/mac_newworld.c
@@ -526,8 +526,14 @@ static void ppc_core99_init(MachineState *machine)
 
 if (g_file_get_contents(filename, _file, _size, NULL)) {
 fw_cfg_add_file(fw_cfg, "ndrv/qemu_vga.ndrv", ndrv_file, 
ndrv_size);
+} else {
+printf("Warning: failed to load driver %s. This may cause video"
+   " problems.\n");
 }
 g_free(filename);
+} else {
+printf("Warning: driver %s not found. This may cause video 
problems.\n",
+   NDRV_VGA_FILENAME);
 }
 
 qemu_register_boot_set(fw_cfg_boot_set, fw_cfg);
diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c
index de2be960e6..96603fe9cf 100644
--- a/hw/ppc/mac_oldworld.c
+++ b/hw/ppc/mac_oldworld.c
@@ -367,8 +367,14 @@ static void ppc_heathrow_init(MachineState *machine)
 
 if (g_file_get_contents(filename, _file, _size, NULL)) {
 fw_cfg_add_file(fw_cfg, "ndrv/qemu_vga.ndrv", ndrv_file, 
ndrv_size);
+} else {
+printf("Warning: failed to load driver %s. This may cause video"
+   " problems.\n");
 }
 g_free(filename);
+} else {
+printf("Warning: driver %s not found. This may cause video 
problems.\n",
+   NDRV_VGA_FILENAME);
 }
 
 qemu_register_boot_set(fw_cfg_boot_set, fw_cfg);
-- 
2.24.3 (Apple Git-128)




[PATCH 0/2] cocoa.m: keyboard quality of life reborn

2021-07-30 Thread John Arbuckle
These patches can really help improve keyboard usage with a guest.
Based on patches by Gustavo Noronha Silva . 

John Arbuckle (2):
  Add full keyboard grab support
  Add ability to swap command/meta and options keys

 ui/cocoa.m | 178 ++---
 1 file changed, 170 insertions(+), 8 deletions(-)

-- 
2.24.3 (Apple Git-128)




[PATCH 1/2] ui/cocoa.m: Add full keyboard grab support

2021-07-30 Thread John Arbuckle
There are keyboard shortcuts that are vital for use in a guest that runs Mac OS.
These shortcuts are reserved for Mac OS use only which makes having the guest
see them impossible on a Mac OS host - until now. This patch will enable the
user to decide if the guest should see all keyboard shortcuts using a menu item.
This patch adds a new menu called Options and a new menu item called
"Full Keyboard Grab". Simply selecting this menu item will turn the feature on
or off at any time. Mac OS requires the user to enable access to assistive
devices to use this feature. How to do this varies with each Mac OS version.
Based on patch by Gustavo Noronha Silva . 

Signed-off-by: John Arbuckle 
---
 ui/cocoa.m | 112 +
 1 file changed, 112 insertions(+)

diff --git a/ui/cocoa.m b/ui/cocoa.m
index 9f72844b07..fdef9e9901 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -114,6 +114,9 @@ static void cocoa_switch(DisplayChangeListener *dcl,
 typedef void (^CodeBlock)(void);
 typedef bool (^BoolCodeBlock)(void);
 
+static CFMachPortRef eventsTap = NULL;
+static CFRunLoopSourceRef eventsTapSource = NULL;
+
 static void with_iothread_lock(CodeBlock block)
 {
 bool locked = qemu_mutex_iothread_locked();
@@ -332,10 +335,27 @@ - (float) cdx;
 - (float) cdy;
 - (QEMUScreen) gscreen;
 - (void) raiseAllKeys;
+- (void) setFullGrab;
 @end
 
 QemuCocoaView *cocoaView;
 
+// Part of the full keyboard grab system
+static CGEventRef handleTapEvent(CGEventTapProxy proxy, CGEventType type,
+CGEventRef cgEvent, void *userInfo)
+{
+QemuCocoaView *cocoaView = (QemuCocoaView*) userInfo;
+NSEvent* event = [NSEvent eventWithCGEvent:cgEvent];
+if ([cocoaView isMouseGrabbed] && [cocoaView handleEvent:event]) {
+COCOA_DEBUG("Global events tap: qemu handled the event, capturing!\n");
+return NULL;
+}
+COCOA_DEBUG("Global events tap: qemu did not handle the event, letting it"
+" through...\n");
+
+return cgEvent;
+}
+
 @implementation QemuCocoaView
 - (id)initWithFrame:(NSRect)frameRect
 {
@@ -361,6 +381,12 @@ - (void) dealloc
 }
 
 qkbd_state_free(kbd);
+if (eventsTap) {
+CFRelease(eventsTap);
+}
+if (eventsTapSource) {
+CFRelease(eventsTapSource);
+}
 [super dealloc];
 }
 
@@ -1086,6 +1112,50 @@ - (void) raiseAllKeys
 qkbd_state_lift_all_keys(kbd);
 });
 }
+
+// Inserts the event tap.
+// This enables us to receive keyboard events that Mac OS would
+// otherwise not let us see - like Command-Option-Esc.
+- (void) setFullGrab
+{
+COCOA_DEBUG("QemuCocoaView: setFullGrab\n");
+NSString *advice = @"Try enabling access to assistive devices";
+CGEventMask mask = CGEventMaskBit(kCGEventKeyDown) |
+CGEventMaskBit(kCGEventKeyUp) | CGEventMaskBit(kCGEventFlagsChanged);
+eventsTap = CGEventTapCreate(kCGHIDEventTap, kCGHeadInsertEventTap,
+ kCGEventTapOptionDefault, mask, 
handleTapEvent,
+ self);
+if (!eventsTap) {
+@throw [NSException
+ exceptionWithName:@"Tap failure"
+reason:[NSString stringWithFormat:@"%@\n%@", @"Could not "
+"create event tap.", advice]
+userInfo:nil];
+} else {
+COCOA_DEBUG("Global events tap created! Will capture system key"
+" combos.\n");
+}
+
+eventsTapSource =
+CFMachPortCreateRunLoopSource(kCFAllocatorDefault, eventsTap, 0);
+if (!eventsTapSource ) {
+@throw [NSException
+ exceptionWithName:@"Tap failure"
+ reason:@"Could not obtain current CFRunLoop source."
+userInfo:nil];
+}
+CFRunLoopRef runLoop = CFRunLoopGetCurrent();
+if (!runLoop) {
+   @throw [NSException
+ exceptionWithName:@"Tap failure"
+ reason:@"Could not obtain current CFRunLoop."
+userInfo:nil];
+}
+
+CFRunLoopAddSource(runLoop, eventsTapSource, kCFRunLoopDefaultMode);
+CFRelease(eventsTapSource);
+}
+
 @end
 
 
@@ -1117,6 +1187,7 @@ - (void)openDocumentation:(NSString *)filename;
 - (IBAction) do_about_menu_item: (id) sender;
 - (void)make_about_window;
 - (void)adjustSpeed:(id)sender;
+- (IBAction)doFullGrab:(id)sender;
 @end
 
 @implementation QemuCocoaAppController
@@ -1569,6 +1640,35 @@ - (void)adjustSpeed:(id)sender
 COCOA_DEBUG("cpu throttling at %d%c\n", cpu_throttle_get_percentage(), 
'%');
 }
 
+// The action method to the 'Options->Full Keyboard Grab' menu item
+- (IBAction)doFullGrab:(id) sender
+{
+@try
+{
+// Set the state of the menu item
+// if already checked
+if ([sender state] == NSControlStateValueOn) {
+// rem

[PATCH 2/2] ui/cocoa.m: Add ability to swap command/meta and options keys

2021-07-30 Thread John Arbuckle
For users who are use to using a Macintosh keyboard having to use a PC keyboard
can be a pain because the Command/meta and Option/Alt keys are switched. To
make life easier this option is added to allow the user to switch how the guest
reacts to each of these keys being pushed. It can make a Macintosh keyboard user
feel almost at home with a PC keyboard. The same could be said for PC keyboard
users who have to use a Macinosh keyboard.
Based on patch by Gustavo Noronha Silva .

Signed-off-by: John Arbuckle 
---
 ui/cocoa.m | 66 +++---
 1 file changed, 58 insertions(+), 8 deletions(-)

diff --git a/ui/cocoa.m b/ui/cocoa.m
index fdef9e9901..98596d5f38 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -116,6 +116,7 @@ static void cocoa_switch(DisplayChangeListener *dcl,
 
 static CFMachPortRef eventsTap = NULL;
 static CFRunLoopSourceRef eventsTapSource = NULL;
+static bool swap_command_option_keys = false;
 
 static void with_iothread_lock(CodeBlock block)
 {
@@ -810,12 +811,22 @@ - (bool) handleEventLocked:(NSEvent *)event
 qkbd_state_key_event(kbd, Q_KEY_CODE_CTRL_R, false);
 }
 if (!(modifiers & NSEventModifierFlagOption)) {
-qkbd_state_key_event(kbd, Q_KEY_CODE_ALT, false);
-qkbd_state_key_event(kbd, Q_KEY_CODE_ALT_R, false);
+if (swap_command_option_keys) {
+qkbd_state_key_event(kbd, Q_KEY_CODE_META_L, false);
+qkbd_state_key_event(kbd, Q_KEY_CODE_META_R, false);
+} else {
+qkbd_state_key_event(kbd, Q_KEY_CODE_ALT, false);
+qkbd_state_key_event(kbd, Q_KEY_CODE_ALT_R, false);
+}
 }
 if (!(modifiers & NSEventModifierFlagCommand)) {
-qkbd_state_key_event(kbd, Q_KEY_CODE_META_L, false);
-qkbd_state_key_event(kbd, Q_KEY_CODE_META_R, false);
+if (swap_command_option_keys) {
+qkbd_state_key_event(kbd, Q_KEY_CODE_ALT, false);
+qkbd_state_key_event(kbd, Q_KEY_CODE_ALT_R, false);
+} else {
+qkbd_state_key_event(kbd, Q_KEY_CODE_META_L, false);
+qkbd_state_key_event(kbd, Q_KEY_CODE_META_R, false);
+}
 }
 
 switch ([event type]) {
@@ -847,13 +858,22 @@ - (bool) handleEventLocked:(NSEvent *)event
 
 case kVK_Option:
 if (!!(modifiers & NSEventModifierFlagOption)) {
-[self toggleKey:Q_KEY_CODE_ALT];
+if (swap_command_option_keys) {
+[self toggleKey:Q_KEY_CODE_META_L];
+} else {
+[self toggleKey:Q_KEY_CODE_ALT];
+}
+
 }
 break;
 
 case kVK_RightOption:
 if (!!(modifiers & NSEventModifierFlagOption)) {
-[self toggleKey:Q_KEY_CODE_ALT_R];
+if (swap_command_option_keys) {
+[self toggleKey:Q_KEY_CODE_META_R];
+} else {
+[self toggleKey:Q_KEY_CODE_ALT_R];
+}
 }
 break;
 
@@ -861,14 +881,22 @@ - (bool) handleEventLocked:(NSEvent *)event
 case kVK_Command:
 if (isMouseGrabbed &&
 !!(modifiers & NSEventModifierFlagCommand)) {
-[self toggleKey:Q_KEY_CODE_META_L];
+if (swap_command_option_keys) {
+[self toggleKey:Q_KEY_CODE_ALT];
+} else {
+[self toggleKey:Q_KEY_CODE_META_L];
+}
 }
 break;
 
 case kVK_RightCommand:
 if (isMouseGrabbed &&
 !!(modifiers & NSEventModifierFlagCommand)) {
-[self toggleKey:Q_KEY_CODE_META_R];
+if (swap_command_option_keys) {
+[self toggleKey:Q_KEY_CODE_ALT_R];
+} else {
+[self toggleKey:Q_KEY_CODE_META_R];
+}
 }
 break;
 }
@@ -1188,6 +1216,7 @@ - (IBAction) do_about_menu_item: (id) sender;
 - (void)make_about_window;
 - (void)adjustSpeed:(id)sender;
 - (IBAction)doFullGrab:(id)sender;
+- (IBAction)doSwapCommandOptionKeys:(id)sender;
 @end
 
 @implementation QemuCocoaAppController
@@ -1669,6 +1698,22 @@ - (IBAction)doFullGrab:(id) sender
 }
 }
 
+// The action method to the "Options->Swap Command and Option Keys" menu item
+- (IBAction)doSwapCommandOptionKeys:(id)sender
+{
+// If the menu item is not checked
+if ([sender state] == NSControlStateValueOff) {
+swap_command_option_keys = true;
+[sender setState: NSControlStateV

[PATCH v2] Set icon for QEMU binary on Mac OS

2021-07-05 Thread John Arbuckle
Signed-off-by: John Arbuckle 
---
v1 changes:
Rewrote the patch as the maintainer had wanted.

 meson.build| 15 ++-
 scripts/entitlement.sh | 10 +-
 2 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/meson.build b/meson.build
index db6789af9c..499ab49981 100644
--- a/meson.build
+++ b/meson.build
@@ -2360,8 +2360,7 @@ foreach target : target_dirs
   endif
   foreach exe: execs
 exe_name = exe['name']
-exe_sign = 'CONFIG_HVF' in config_target
-if exe_sign
+if targetos == 'darwin'
   exe_name += '-unsigned'
 endif
 
@@ -2375,7 +2374,13 @@ foreach target : target_dirs
link_args: link_args,
gui_app: exe['gui'])
 
-if exe_sign
+if 'CONFIG_HVF' in config_target
+  entitlements = meson.current_source_dir() / 
'accel/hvf/entitlements.plist'
+else
+  entitlements = '/dev/null'
+endif
+if targetos == 'darwin'
+  icon = '...'
   emulators += {exe['name'] : custom_target(exe['name'],
depends: emulator,
output: exe['name'],
@@ -2383,14 +2388,14 @@ foreach target : target_dirs
  meson.current_source_dir() / 'scripts/entitlement.sh',
  meson.current_build_dir() / exe_name,
  meson.current_build_dir() / exe['name'],
- meson.current_source_dir() / 
'accel/hvf/entitlements.plist'
+ entitlements, icon
])
   }
 
   meson.add_install_script('scripts/entitlement.sh', '--install',
get_option('bindir') / exe_name,
get_option('bindir') / exe['name'],
-   meson.current_source_dir() / 
'accel/hvf/entitlements.plist')
+   entitlements, icon)
 else
   emulators += {exe['name']: emulator}
 endif
diff --git a/scripts/entitlement.sh b/scripts/entitlement.sh
index f7aaaf2766..46e378426b 100755
--- a/scripts/entitlement.sh
+++ b/scripts/entitlement.sh
@@ -11,6 +11,7 @@ fi
 SRC="$1"
 DST="$2"
 ENTITLEMENT="$3"
+ICON="$4"
 
 if $in_place; then
   trap 'rm "$DST.tmp"' exit
@@ -20,6 +21,13 @@ else
   cd "$MESON_INSTALL_DESTDIR_PREFIX"
 fi
 
-codesign --entitlements "$ENTITLEMENT" --force -s - "$SRC"
+if test "$ENTITLEMENT" != '/dev/null'; then
+  codesign --entitlements "$ENTITLEMENT" --force -s - "$SRC"
+fi
+
+# Add the QEMU icon to the binary on Mac OS
+Rez -append '../pc-bios/qemu.rsrc' -o "$SRC"
+SetFile -a C "$SRC"
+
 mv -f "$SRC" "$DST"
 trap '' exit
-- 
2.24.3 (Apple Git-128)




[Bug 1927408] Re: USB Ethernet device (RNDIS) does not work on several tested operating systems

2021-05-06 Thread John Arbuckle
See https://gitlab.com/qemu-project/qemu/-/issues/198 for further
updates.

** Bug watch added: gitlab.com/qemu-project/qemu/-/issues #198
   https://gitlab.com/qemu-project/qemu/-/issues/198

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1927408

Title:
  USB Ethernet device (RNDIS) does not work on several tested operating
  systems

Status in QEMU:
  Won't Fix

Bug description:
  The USB ethernet device does not work on most versions of operating
  systems I have tested. For each operating system the command to use
  this device was: -netdev user,id=mynet1 -device usb-net,netdev=mynet1.

  
  Windows 2000 (qemu-system-i386):
  - failed to load a driver for the device

  
  Windows 7 (qemu-system-x86_64):
  - Did not find a driver
  - Followed the directions here: 
https://developer.toradex.com/knowledge-base/how-to-install-microsoft-rndis-driver-for-windows-7
  -- The device failed to start with error 10.
  - Did see this message in the terminal on the host: 
  usbnet: failed control transaction: request 0x8006 value 0x600 index 0x0 
length 0xa

  
  Mac OS 10.4.11 (qemu-system-ppc):
  - It actually works.
  - did see these messages in the terminal on the host:
  usbnet: failed control transaction: request 0x2143 value 0x1c index 0x0 
length 0x0
  usbnet: failed control transaction: request 0x2143 value 0x1e index 0x0 
length 0x0

  
  Mac OS 10.8.5 (qemu-system-x86_64):
  - Fails to obtain IP address using DHCP.
  - The Network pane does say the device is connected. 
  - A self-assigned IP address is given: 169.254.186.53.
  -- It still did not work
  - Did see this message in the terminal of the host:
  usbnet: failed control transaction: request 0x2143 value 0x1c index 0x0 
length 0x0
  usbnet: failed control transaction: request 0x2143 value 0x1e index 0x0 
length 0x0

  
  Mac OS 10.2.3 (qemu-system-ppc):
  - Did not appear to detect the USB NIC. Did not see it in the network pane.
  - Apple System Profiler does see this device.
  - Saw this message in there terminal of the host: qemu-system-ppc: Slirp: 
Failed to send packet, ret: -1

  
  Mac OS 9.2 (qemu-system-ppc):
  - Apple System Profiler does show the device connected.
  - The Tcp/ip control panel did not detect this device.

  
  My guess is this device is buggy. If anyone has any tips or suggestions 
please let me know.

  Thank you.

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1927408/+subscriptions



[Bug 1927408] [NEW] USB Ethernet device (RNDIS) does not work on several tested operating systems

2021-05-06 Thread John Arbuckle
Public bug reported:

The USB ethernet device does not work on most versions of operating
systems I have tested. For each operating system the command to use this
device was: -netdev user,id=mynet1 -device usb-net,netdev=mynet1.


Windows 2000 (qemu-system-i386):
- failed to load a driver for the device


Windows 7 (qemu-system-x86_64):
- Did not find a driver
- Followed the directions here: 
https://developer.toradex.com/knowledge-base/how-to-install-microsoft-rndis-driver-for-windows-7
-- The device failed to start with error 10.
- Did see this message in the terminal on the host: 
usbnet: failed control transaction: request 0x8006 value 0x600 index 0x0 length 
0xa


Mac OS 10.4.11 (qemu-system-ppc):
- It actually works.
- did see these messages in the terminal on the host:
usbnet: failed control transaction: request 0x2143 value 0x1c index 0x0 length 
0x0
usbnet: failed control transaction: request 0x2143 value 0x1e index 0x0 length 
0x0


Mac OS 10.8.5 (qemu-system-x86_64):
- Fails to obtain IP address using DHCP.
- The Network pane does say the device is connected. 
- A self-assigned IP address is given: 169.254.186.53.
-- It still did not work
- Did see this message in the terminal of the host:
usbnet: failed control transaction: request 0x2143 value 0x1c index 0x0 length 
0x0
usbnet: failed control transaction: request 0x2143 value 0x1e index 0x0 length 
0x0


Mac OS 10.2.3 (qemu-system-ppc):
- Did not appear to detect the USB NIC. Did not see it in the network pane.
- Apple System Profiler does see this device.
- Saw this message in there terminal of the host: qemu-system-ppc: Slirp: 
Failed to send packet, ret: -1


Mac OS 9.2 (qemu-system-ppc):
- Apple System Profiler does show the device connected.
- The Tcp/ip control panel did not detect this device.


My guess is this device is buggy. If anyone has any tips or suggestions please 
let me know.

Thank you.

** Affects: qemu
 Importance: Undecided
 Status: New

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1927408

Title:
  USB Ethernet device (RNDIS) does not work on several tested operating
  systems

Status in QEMU:
  New

Bug description:
  The USB ethernet device does not work on most versions of operating
  systems I have tested. For each operating system the command to use
  this device was: -netdev user,id=mynet1 -device usb-net,netdev=mynet1.

  
  Windows 2000 (qemu-system-i386):
  - failed to load a driver for the device

  
  Windows 7 (qemu-system-x86_64):
  - Did not find a driver
  - Followed the directions here: 
https://developer.toradex.com/knowledge-base/how-to-install-microsoft-rndis-driver-for-windows-7
  -- The device failed to start with error 10.
  - Did see this message in the terminal on the host: 
  usbnet: failed control transaction: request 0x8006 value 0x600 index 0x0 
length 0xa

  
  Mac OS 10.4.11 (qemu-system-ppc):
  - It actually works.
  - did see these messages in the terminal on the host:
  usbnet: failed control transaction: request 0x2143 value 0x1c index 0x0 
length 0x0
  usbnet: failed control transaction: request 0x2143 value 0x1e index 0x0 
length 0x0

  
  Mac OS 10.8.5 (qemu-system-x86_64):
  - Fails to obtain IP address using DHCP.
  - The Network pane does say the device is connected. 
  - A self-assigned IP address is given: 169.254.186.53.
  -- It still did not work
  - Did see this message in the terminal of the host:
  usbnet: failed control transaction: request 0x2143 value 0x1c index 0x0 
length 0x0
  usbnet: failed control transaction: request 0x2143 value 0x1e index 0x0 
length 0x0

  
  Mac OS 10.2.3 (qemu-system-ppc):
  - Did not appear to detect the USB NIC. Did not see it in the network pane.
  - Apple System Profiler does see this device.
  - Saw this message in there terminal of the host: qemu-system-ppc: Slirp: 
Failed to send packet, ret: -1

  
  Mac OS 9.2 (qemu-system-ppc):
  - Apple System Profiler does show the device connected.
  - The Tcp/ip control panel did not detect this device.

  
  My guess is this device is buggy. If anyone has any tips or suggestions 
please let me know.

  Thank you.

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1927408/+subscriptions



[Bug 1785485] Re: Mouse moves erratically when using scroll wheel on Windows NT 4, Windows 95, and Windows 3.1 guests

2021-05-02 Thread John Arbuckle
After doing tests with Windows 95, 3,1, NT 4.0, and 2000 I can say this
bug appears to be fixed.

** Changed in: qemu
   Status: Incomplete => Fix Released

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1785485

Title:
  Mouse moves erratically when using scroll wheel on Windows NT 4,
  Windows 95, and Windows 3.1 guests

Status in QEMU:
  Fix Released

Bug description:
  QEMU version: 3.0.0 RC3
  Guests: Windows NT 4.0, Windows 95, Windows 3.1

  Program: When the user uses the scroll wheel, the mouse's movement
  becomes erratic.

  This is noticed immediately when the scroll wheel is used. Sometimes
  the problem can be fixed by moving the scroll wheel some more.

  My theory is this problem is because of the lack of support for the
  Microsoft Intellimouse in these guest operating systems.

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1785485/+subscriptions



[Bug 1850570] Re: Cannot use usb-host on Mac OS

2021-04-04 Thread John Arbuckle
I am also having problems with using real USB devices. I tried a C-Media
USB sound card, a CISCO USB headset, and a PNY flash drive. All of them
seem to be detected by the Windows 7 guest, but can't be started for
some reason. I have tried running as root. I didn't see any libusb
errors. My Windows 2000 guest also has issues with starting the USB
sound card.

My command-line:
sudo qemu-system-x86_64 -hda "Windows 7 HD.qcow2" -boot "c" -m 5000 -device 
ich9-usb-ehci1 -device usb-host,vendorid=0x0930,productid=0x6545

Even when I unmount the flash drive first Mac OS 11.1 will actually
mount the flash drive when I try using it in QEMU.

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1850570

Title:
  Cannot use usb-host on Mac OS

Status in QEMU:
  New

Bug description:
  Usb-host will not work on Mac OS 10.15.  Qemu runs, though it gives
  these errors and the drive does not show up.  Also, when Qemu is
  starting the drive ejects and remounts twice. Qemu built with
  ./configure --target-list=i386-softmmu,x86_64-softmmu --enable-sdl
  --disable-cocoa --enable-sdl-image.

  qemu-system-i386 image.qcow -usb -device usb-kbd  -device 
usb-host,vendorid=0x0781,productid=0x5571
  libusb: error [darwin_claim_interface] USBInterfaceOpen: another process has 
device opened for exclusive access
  libusb: error [darwin_claim_interface] interface not found
  libusb: error [darwin_claim_interface] interface not found
  libusb: error [darwin_claim_interface] interface not found
  libusb: error [darwin_claim_interface] interface not found
  libusb: error [darwin_claim_interface] interface not found
  libusb: error [darwin_claim_interface] interface not found
  libusb: error [darwin_claim_interface] interface not found
  libusb: error [darwin_claim_interface] interface not found
  libusb: error [darwin_claim_interface] interface not found
  libusb: error [darwin_claim_interface] interface not found
  libusb: error [darwin_claim_interface] interface not found
  libusb: error [darwin_claim_interface] interface not found
  libusb: error [darwin_claim_interface] interface not found
  libusb: error [darwin_claim_interface] interface not found
  libusb: error [darwin_claim_interface] interface not found
  libusb: error [darwin_claim_interface] USBInterfaceOpen: another process has 
device opened for exclusive access
  libusb: error [darwin_claim_interface] interface not found
  libusb: error [darwin_claim_interface] interface not found
  libusb: error [darwin_claim_interface] interface not found
  libusb: error [darwin_claim_interface] interface not found
  libusb: error [darwin_claim_interface] interface not found
  libusb: error [darwin_claim_interface] interface not found
  libusb: error [darwin_claim_interface] interface not found
  libusb: error [darwin_claim_interface] interface not found
  libusb: error [darwin_claim_interface] interface not found
  libusb: error [darwin_claim_interface] interface not found
  libusb: error [darwin_claim_interface] interface not found
  libusb: error [darwin_claim_interface] interface not found
  libusb: error [darwin_claim_interface] interface not found
  libusb: error [darwin_claim_interface] interface not found
  libusb: error [darwin_claim_interface] interface not found

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1850570/+subscriptions



[Bug 1917161] Re: Parameter 'type' expects a netdev backend type

2021-03-15 Thread John Arbuckle
I looks like the solution to my problem was to delete the slirp folder,
then do a 'git pull', then make QEMU again. Networking is working again.

** Changed in: qemu
   Status: Incomplete => Fix Released

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1917161

Title:
  Parameter 'type' expects a netdev backend type

Status in QEMU:
  Fix Released

Bug description:
  When using QEMU on an M1 Mac with Mac OS 11.1, I see this error
  message when trying to enable networking for a guest:

  Parameter 'type' expects a netdev backend type

  Example command:
  qemu-system-i386 -m 700 -hda  -netdev user,id=n0 -device 
rtl8139,netdev=n0

  What should happen is networking should work when issuing the above
  command. What actually happens is QEMU exits immediately.

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1917161/+subscriptions



Re: [Bug 1917161] Parameter 'type' expects a netdev backend type

2021-03-02 Thread John Arbuckle
I see 14 files in the src folder in the slirp folder.
I am using git.
This is what I see when I run git submodule:

objc[1854]: Class AMSupportURLConnectionDelegate is implemented in both ?? 
(0x203eaf8f0) and ?? (0x1147702b8). One of the two will be used. Which one is 
undefined.
objc[1854]: Class AMSupportURLSession is implemented in both ?? (0x203eaf940) 
and ?? (0x114770308). One of the two will be used. Which one is undefined.
 f8b1b833015a4ae47110ed068e0deb7106ced66d capstone (4.0.1-548-gf8b1b833)
 85e5d839847af54efab170f2b1331b2a6421e647 dtc (v1.6.0-4-g85e5d83)
 776acd2a805c9b42b4f0375150977df42130317f meson (0.55.3)
-90c488d5f4a407342247b9ea869df1c2d9c8e266 roms/QemuMacDrivers
-e18ddad8516ff2cfe36ec130200318f7251aa78c roms/SLOF
-06dc822d045c2bb42e497487935485302486e151 roms/edk2
-4bd064de239dab2426b31c9789a1f4d78087dc63 roms/ipxe
-7f28286f5cb1ca682e3ba0a8706d8884f12bc49e roms/openbios
-a98258d0b537a295f517bbc8d813007336731fa9 roms/opensbi
-a5300c4949b8d4de2d34bedfaed66793f48ec948 roms/qboot
-bf0e13698872450164fa7040da36a95d2d4b326f roms/qemu-palcode
-155821a1990b6de78dde5f98fa5ab90e802021e0 roms/seabios
-73b740f77190643b2ada5ee97a9a108c6ef2a37b roms/seabios-hppa
-cbaee52287e5f32373181cff50a00b6c4ac9015a roms/sgabios
-3a6fdede6ce117facec0108afe716cf5d0472c3f roms/skiboot
-d3689267f92c5956e09cc7d1baa4700141662bff roms/u-boot
-60b3916f33e617a815973c5a6df77055b2e3a588 roms/u-boot-sam460ex
-0c37a43527f0ee2b9584e7fb2fdc805e902635ac roms/vbootrom
 8f43a99191afb47ca3f3c6972f6306209f367ece slirp (v4.2.0-26-g8f43a99)
 b64af41c3276f97f0e181920400ee056b9c88037 tests/fp/berkeley-softfloat-3 
(heads/master)
 5a59dcec19327396a011a17fd924aed4fec416b3 tests/fp/berkeley-testfloat-3 
(remotes/origin/HEAD)
 6119e6e19a050df847418de7babe5166779955e4 ui/keycodemapdb (remotes/origin/HEAD)


> On Mar 2, 2021, at 1:37 AM, Thomas Huth <1917...@bugs.launchpad.net> wrote:
> 
> Yes, QEMU should come with the libslirp sources. Are you using git? Then
> maybe something went wrong with the checkout of the submodule. Is there
> something in your "slirp" folder? What do you get when you run "git
> submodule" ?
> 
> -- 
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1917161
> 
> Title:
>  Parameter 'type' expects a netdev backend type
> 
> Status in QEMU:
>  Incomplete
> 
> Bug description:
>  When using QEMU on an M1 Mac with Mac OS 11.1, I see this error
>  message when trying to enable networking for a guest:
> 
>  Parameter 'type' expects a netdev backend type
> 
>  Example command:
>  qemu-system-i386 -m 700 -hda  -netdev user,id=n0 -device 
> rtl8139,netdev=n0
> 
>  What should happen is networking should work when issuing the above
>  command. What actually happens is QEMU exits immediately.
> 
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/qemu/+bug/1917161/+subscriptions

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1917161

Title:
  Parameter 'type' expects a netdev backend type

Status in QEMU:
  Incomplete

Bug description:
  When using QEMU on an M1 Mac with Mac OS 11.1, I see this error
  message when trying to enable networking for a guest:

  Parameter 'type' expects a netdev backend type

  Example command:
  qemu-system-i386 -m 700 -hda  -netdev user,id=n0 -device 
rtl8139,netdev=n0

  What should happen is networking should work when issuing the above
  command. What actually happens is QEMU exits immediately.

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1917161/+subscriptions



[Bug 1917161] Re: Parameter 'type' expects a netdev backend type

2021-03-01 Thread John Arbuckle
I did try './configure --target-list=i386-softmmu --enable-slirp' but it
failed with this error message:

Run-time dependency slirp found: NO (tried pkgconfig)

../meson.build:1498:4: ERROR: Dependency "slirp" not found, tried
pkgconfig

I thought slirp came with QEMU. I do see a slirp folder packaged with
QEMU.

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1917161

Title:
  Parameter 'type' expects a netdev backend type

Status in QEMU:
  Incomplete

Bug description:
  When using QEMU on an M1 Mac with Mac OS 11.1, I see this error
  message when trying to enable networking for a guest:

  Parameter 'type' expects a netdev backend type

  Example command:
  qemu-system-i386 -m 700 -hda  -netdev user,id=n0 -device 
rtl8139,netdev=n0

  What should happen is networking should work when issuing the above
  command. What actually happens is QEMU exits immediately.

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1917161/+subscriptions



[Bug 1917161] [NEW] Parameter 'type' expects a netdev backend type

2021-02-27 Thread John Arbuckle
Public bug reported:

When using QEMU on an M1 Mac with Mac OS 11.1, I see this error message
when trying to enable networking for a guest:

Parameter 'type' expects a netdev backend type

Example command:
qemu-system-i386 -m 700 -hda  -netdev user,id=n0 -device 
rtl8139,netdev=n0

What should happen is networking should work when issuing the above
command. What actually happens is QEMU exits immediately.

** Affects: qemu
 Importance: Undecided
 Status: New

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1917161

Title:
  Parameter 'type' expects a netdev backend type

Status in QEMU:
  New

Bug description:
  When using QEMU on an M1 Mac with Mac OS 11.1, I see this error
  message when trying to enable networking for a guest:

  Parameter 'type' expects a netdev backend type

  Example command:
  qemu-system-i386 -m 700 -hda  -netdev user,id=n0 -device 
rtl8139,netdev=n0

  What should happen is networking should work when issuing the above
  command. What actually happens is QEMU exits immediately.

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1917161/+subscriptions



[Bug 1916344] Re: User mode networking not working properly on QEMU on Mac OS X host

2021-02-24 Thread John Arbuckle
I'm on Mac OS 11.1 on an M1 Mac. I did some tests with QEMU 2.10.1 and
5.3 and here are the results:

QEMU 2.10.1:
- Ran Windows XP as a guest
- qemu-system-i386 -m 700 -hda  -netdev user,id=n0 -device 
rtl8139,netdev=n0
- Internet Explorer was able to load a web page.

QEMU 5.3.x:
- Tried to run Windows XP as a guest:
- qemu-system-i386 -m 700 -hda  -netdev user,id=n0 -device 
rtl8139,netdev=n0
- QEMU refused to run and displayed this error message: qemu-system-i386: 
-netdev user,id=n0: Parameter 'type' expects a netdev backend type

I'm not sure if this message is a bug or something else.

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1916344

Title:
  User mode networking not working properly on QEMU on Mac OS X host

Status in QEMU:
  New

Bug description:
  Steps to reproduce:

  1. Install QEMU using homebrew on Mac OS X (I tried on Catalina and Big Sur)
  2. Spin up a guest VM (say) Cent OS 8 using user mode networking.
  3. Install podman inside the guest
  4. Run podman pull alpine

  The result is:

  [root@localhost ~]# podman pull alpine
  Resolved "alpine" as an alias 
(/etc/containers/registries.conf.d/shortnames.conf)
  Trying to pull docker.io/library/alpine:latest...
  Getting image source signatures
  Copying blob ba3557a56b15 [==] 2.7MiB / 
2.7MiB
    unexpected EOF
  Error: Error writing blob: error storing blob to file 
"/var/tmp/storage851171596/1": error happened during read: unexpected EOF

  This is happening because QEMU is telling the guest that the TCP
  connection is closed even before reading all the data from the host
  socket and forwarding it to the guest.

  This issue doesn't happen on a Linux host. So, that tells me that this
  has something to do with QEMU installation on Mac OS X.

  This could be a slirp related issue. So, QEMU/slirp may need to work
  together on fixing this. Here's the link to the libslirp issue:

  https://gitlab.freedesktop.org/slirp/libslirp/-/issues/35

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1916344/+subscriptions



[Bug 1916344] Re: User mode networking not working properly on QEMU on Mac OS X host

2021-02-21 Thread John Arbuckle
I built QEMU from the git repo. My Windows XP and Mac OS 10.4 guests
cannot access the internet. I'm on a M1 Mac running Mac OS 11.1. I use
qemu-system-i386 and qemu-system-ppc.

I tried installing slirp from MacPorts but it is broken. It might have
been broken for years. See https://trac.macports.org/ticket/41875. So
slirp networking probably isn't going to work.



** Bug watch added: trac.macports.org #41875
   http://trac.macports.org/ticket/41875

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1916344

Title:
  User mode networking not working properly on QEMU on Mac OS X host

Status in QEMU:
  New

Bug description:
  Steps to reproduce:

  1. Install QEMU using homebrew on Mac OS X (I tried on Catalina and Big Sur)
  2. Spin up a guest VM (say) Cent OS 8 using user mode networking.
  3. Install podman inside the guest
  4. Run podman pull alpine

  The result is:

  [root@localhost ~]# podman pull alpine
  Resolved "alpine" as an alias 
(/etc/containers/registries.conf.d/shortnames.conf)
  Trying to pull docker.io/library/alpine:latest...
  Getting image source signatures
  Copying blob ba3557a56b15 [==] 2.7MiB / 
2.7MiB
    unexpected EOF
  Error: Error writing blob: error storing blob to file 
"/var/tmp/storage851171596/1": error happened during read: unexpected EOF

  This is happening because QEMU is telling the guest that the TCP
  connection is closed even before reading all the data from the host
  socket and forwarding it to the guest.

  This issue doesn't happen on a Linux host. So, that tells me that this
  has something to do with QEMU installation on Mac OS X.

  This could be a slirp related issue. So, QEMU/slirp may need to work
  together on fixing this. Here's the link to the libslirp issue:

  https://gitlab.freedesktop.org/slirp/libslirp/-/issues/35

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1916344/+subscriptions



[Bug 1914294] Re: Windows XP displays black screen when smp option is used

2021-02-15 Thread John Arbuckle
To fix this problem open Windows XP's System Restore and restore from a
point before using the smp option.

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1914294

Title:
  Windows XP displays black screen when smp option is used

Status in QEMU:
  New

Bug description:
  When I use Windows XP with the -smp option, the screen goes black. The
  only thing I can see is a cursor. I have tried -smp 2, -smp cores=4,
  and -smp cores=2.

  My info:

  Host:
  M1 Mac
  Mac OS 11.1
  QEMU 5.2 at cf7ca7d5b9faca13f1f8e3ea92cfb2f741eb0c0e.

  Guest:
  32-bit Windows XP SP3 build 2600.

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1914294/+subscriptions



[Bug 1914667] Re: High cpu usage when guest is idle on qemu-system-i386

2021-02-10 Thread John Arbuckle
I found a way to fix the high host cpu usage issue. To fix this issue
click on Start->All Programs->Accessories->System Tools->System Restore.
Then pick a restore point that is set before you tried the smp option.
After the VM restarts the high CPU usage issue will be gone :)

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1914667

Title:
  High cpu usage when guest is idle on qemu-system-i386

Status in QEMU:
  New

Bug description:
  When running Windows XP in qemu-system-i386, the cpu usage of QEMU is
  about 100% even when the guest CPU usage is close to 2%. The host cpu
  usage should be low when the guest cpu usage is low.

  Command: qemu-system-i386 -hda 

  Using this command also shows around 100% host CPU usage:
  qemu-system-i386 -m 700 -hda  -usb -device usb-audio 
-net nic,model=rtl8139 -net user -hdb mountable.img -soundhw pcspk

  Using the Penryn CPU option also saw this problem:
  qemu-system-i386 -hda  -m 700 -cpu Penryn-v1

  Using "-cpu pentium2" saw the same high host cpu usage.

  
  My Info:
  M1 MacBook Air
  Mac OS 11.1
  qemu-system-i386 version 5.2 (1ba089f2255bfdb071be3ce6ac6c3069e8012179)
  Windows XP SP3 Build 2600

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1914667/+subscriptions



[Bug 1914294] Re: Windows XP displays black screen when smp option is used

2021-02-10 Thread John Arbuckle
Command line to reproduce this issue: 
qemu-system-i386 -m 700 -hda  -smp 2

Last commit tested with this problem:
1214d55d1c41fbab3a9973a05085b8760647e411

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1914294

Title:
  Windows XP displays black screen when smp option is used

Status in QEMU:
  New

Bug description:
  When I use Windows XP with the -smp option, the screen goes black. The
  only thing I can see is a cursor. I have tried -smp 2, -smp cores=4,
  and -smp cores=2.

  My info:

  Host:
  M1 Mac
  Mac OS 11.1
  QEMU 5.2 at cf7ca7d5b9faca13f1f8e3ea92cfb2f741eb0c0e.

  Guest:
  32-bit Windows XP SP3 build 2600.

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1914294/+subscriptions



[Bug 1914294] Re: Windows XP displays black screen when smp option is used

2021-02-10 Thread John Arbuckle
I restarted QEMU without the '-smp 2' option and Windows XP started
working again. The only problem is the host CPU usage will stay at 100%
even with the guest CPU load being close to 0%. The only way to fix this
problem that I know currently is to reinstall Windows XP.

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1914294

Title:
  Windows XP displays black screen when smp option is used

Status in QEMU:
  New

Bug description:
  When I use Windows XP with the -smp option, the screen goes black. The
  only thing I can see is a cursor. I have tried -smp 2, -smp cores=4,
  and -smp cores=2.

  My info:

  Host:
  M1 Mac
  Mac OS 11.1
  QEMU 5.2 at cf7ca7d5b9faca13f1f8e3ea92cfb2f741eb0c0e.

  Guest:
  32-bit Windows XP SP3 build 2600.

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1914294/+subscriptions



[Bug 1914667] Re: High cpu usage when guest is idle on qemu-system-i386

2021-02-10 Thread John Arbuckle
After updating QEMU to 1214d55d1c41fbab3a9973a05085b8760647e411, I
reinstalled Windows XP and the host CPU usage at idle was normal. My
guess is that I picked a bad commit to reinstall Windows XP.

I tried using "-smp 4". Windows XP started up to a black screen. When I
restarted the problem with high CPU usage at idle was back. I did not
use the "-smp 4" option after restarting.

When I first specified the '-smp 4' option I saw Windows install
something then have the computer restarted.

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1914667

Title:
  High cpu usage when guest is idle on qemu-system-i386

Status in QEMU:
  New

Bug description:
  When running Windows XP in qemu-system-i386, the cpu usage of QEMU is
  about 100% even when the guest CPU usage is close to 2%. The host cpu
  usage should be low when the guest cpu usage is low.

  Command: qemu-system-i386 -hda 

  Using this command also shows around 100% host CPU usage:
  qemu-system-i386 -m 700 -hda  -usb -device usb-audio 
-net nic,model=rtl8139 -net user -hdb mountable.img -soundhw pcspk

  Using the Penryn CPU option also saw this problem:
  qemu-system-i386 -hda  -m 700 -cpu Penryn-v1

  Using "-cpu pentium2" saw the same high host cpu usage.

  
  My Info:
  M1 MacBook Air
  Mac OS 11.1
  qemu-system-i386 version 5.2 (1ba089f2255bfdb071be3ce6ac6c3069e8012179)
  Windows XP SP3 Build 2600

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1914667/+subscriptions



[Bug 1913505] Re: Windows XP slow on Apple M1

2021-02-10 Thread John Arbuckle
Just to note when I tried reinstalling Windows XP, the installation
appeared to be stuck at this screen. I restarted QEMU to continue.


** Attachment added: "Windows XP stuck.png"
   
https://bugs.launchpad.net/qemu/+bug/1913505/+attachment/5462351/+files/Windows%20XP%20stuck.png

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1913505

Title:
  Windows XP slow on Apple M1

Status in QEMU:
  New

Bug description:
  Qemu installed by using brew install qemu -s on M1

  QEMU emulator version 5.2.0
  XP image from: https://archive.org/details/WinXPProSP3x86

  Commands run:
  $ qemu-img create -f qcow2 xpsp3.img 10G
  $ qemu-system-i386 -m 512 -hda xpsp3.img -cdrom 
WinXPProSP3x86/en_windows_xp_professional_with_service_pack_3_x86_cd_vl_x14-73974.iso
 -boot d

  It's taken 3 days now with qemu running at around 94% CPU and
  installation hasn't finished. The mouse pointer moves and occasionally
  changes between the pointer and hourglass so it doesn't seem to have
  frozen.

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1913505/+subscriptions



[Bug 1913505] Re: Windows XP slow on Apple M1

2021-02-10 Thread John Arbuckle
Tried the patch.
Start up time does not appear to be improved.
I used both qemu-system-i386 and qemu-system-x86_64 with the same results.
To compare notes I tried Windows 7. It starts up much faster than Windows XP.

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1913505

Title:
  Windows XP slow on Apple M1

Status in QEMU:
  New

Bug description:
  Qemu installed by using brew install qemu -s on M1

  QEMU emulator version 5.2.0
  XP image from: https://archive.org/details/WinXPProSP3x86

  Commands run:
  $ qemu-img create -f qcow2 xpsp3.img 10G
  $ qemu-system-i386 -m 512 -hda xpsp3.img -cdrom 
WinXPProSP3x86/en_windows_xp_professional_with_service_pack_3_x86_cd_vl_x14-73974.iso
 -boot d

  It's taken 3 days now with qemu running at around 94% CPU and
  installation hasn't finished. The mouse pointer moves and occasionally
  changes between the pointer and hourglass so it doesn't seem to have
  frozen.

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1913505/+subscriptions



[Bug 1913505] Re: Windows XP slow on Apple M1

2021-02-08 Thread John Arbuckle
I installed QEMU thru home-brew. When I tried to run it I saw this error
message: "Could not allocate dynamic translator buffer".

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1913505

Title:
  Windows XP slow on Apple M1

Status in QEMU:
  New

Bug description:
  Qemu installed by using brew install qemu -s on M1

  QEMU emulator version 5.2.0
  XP image from: https://archive.org/details/WinXPProSP3x86

  Commands run:
  $ qemu-img create -f qcow2 xpsp3.img 10G
  $ qemu-system-i386 -m 512 -hda xpsp3.img -cdrom 
WinXPProSP3x86/en_windows_xp_professional_with_service_pack_3_x86_cd_vl_x14-73974.iso
 -boot d

  It's taken 3 days now with qemu running at around 94% CPU and
  installation hasn't finished. The mouse pointer moves and occasionally
  changes between the pointer and hourglass so it doesn't seem to have
  frozen.

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1913505/+subscriptions



[Bug 1914667] Re: High cpu usage when guest is idle on qemu-system-i386

2021-02-04 Thread John Arbuckle
For version 5.2 of qemu-system-i386 the instruction the guest is busy
executing over and over again is this: addb %al, (%eax)

For version 2.10.1 this is the instruction that is being executed when the 
guest is idle:
add %al,(%eax)

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1914667

Title:
  High cpu usage when guest is idle on qemu-system-i386

Status in QEMU:
  New

Bug description:
  When running Windows XP in qemu-system-i386, the cpu usage of QEMU is
  about 100% even when the guest CPU usage is close to 2%. The host cpu
  usage should be low when the guest cpu usage is low.

  Command: qemu-system-i386 -hda 

  Using this command also shows around 100% host CPU usage:
  qemu-system-i386 -m 700 -hda  -usb -device usb-audio 
-net nic,model=rtl8139 -net user -hdb mountable.img -soundhw pcspk

  Using the Penryn CPU option also saw this problem:
  qemu-system-i386 -hda  -m 700 -cpu Penryn-v1

  Using "-cpu pentium2" saw the same high host cpu usage.

  
  My Info:
  M1 MacBook Air
  Mac OS 11.1
  qemu-system-i386 version 5.2 (1ba089f2255bfdb071be3ce6ac6c3069e8012179)
  Windows XP SP3 Build 2600

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1914667/+subscriptions



[Bug 1914667] Re: High cpu usage when guest is idle on qemu-system-i386

2021-02-04 Thread John Arbuckle
Just to compare notes I ran my same Windows XP image on an older version
of QEMU. This is version 2.10.1. It was built for the x86_64
architecture. The host CPU architecture is aarm64. The host CPU usage
was actually very low when the guest CPU usage was low. The guest was
using about 8% and the host usage was around 14%.

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1914667

Title:
  High cpu usage when guest is idle on qemu-system-i386

Status in QEMU:
  New

Bug description:
  When running Windows XP in qemu-system-i386, the cpu usage of QEMU is
  about 100% even when the guest CPU usage is close to 2%. The host cpu
  usage should be low when the guest cpu usage is low.

  Command: qemu-system-i386 -hda 

  Using this command also shows around 100% host CPU usage:
  qemu-system-i386 -m 700 -hda  -usb -device usb-audio 
-net nic,model=rtl8139 -net user -hdb mountable.img -soundhw pcspk

  Using the Penryn CPU option also saw this problem:
  qemu-system-i386 -hda  -m 700 -cpu Penryn-v1

  Using "-cpu pentium2" saw the same high host cpu usage.

  
  My Info:
  M1 MacBook Air
  Mac OS 11.1
  qemu-system-i386 version 5.2 (1ba089f2255bfdb071be3ce6ac6c3069e8012179)
  Windows XP SP3 Build 2600

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1914667/+subscriptions



[Bug 1914667] [NEW] High cpu usage when guest is idle on qemu-system-i386

2021-02-04 Thread John Arbuckle
Public bug reported:

When running Windows XP in qemu-system-i386, the cpu usage of QEMU is
about 100% even when the guest CPU usage is close to 2%. The host cpu
usage should be low when the guest cpu usage is low.

Command: qemu-system-i386 -hda 

Using this command also shows around 100% host CPU usage:
qemu-system-i386 -m 700 -hda  -usb -device usb-audio -net 
nic,model=rtl8139 -net user -hdb mountable.img -soundhw pcspk

Using the Penryn CPU option also saw this problem:
qemu-system-i386 -hda  -m 700 -cpu Penryn-v1

Using "-cpu pentium2" saw the same high host cpu usage.


My Info:
M1 MacBook Air
Mac OS 11.1
qemu-system-i386 version 5.2 (1ba089f2255bfdb071be3ce6ac6c3069e8012179)
Windows XP SP3 Build 2600

** Affects: qemu
 Importance: Undecided
 Status: New

** Attachment added: "high cpu usage.png"
   
https://bugs.launchpad.net/bugs/1914667/+attachment/5460096/+files/high%20cpu%20usage.png

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1914667

Title:
  High cpu usage when guest is idle on qemu-system-i386

Status in QEMU:
  New

Bug description:
  When running Windows XP in qemu-system-i386, the cpu usage of QEMU is
  about 100% even when the guest CPU usage is close to 2%. The host cpu
  usage should be low when the guest cpu usage is low.

  Command: qemu-system-i386 -hda 

  Using this command also shows around 100% host CPU usage:
  qemu-system-i386 -m 700 -hda  -usb -device usb-audio 
-net nic,model=rtl8139 -net user -hdb mountable.img -soundhw pcspk

  Using the Penryn CPU option also saw this problem:
  qemu-system-i386 -hda  -m 700 -cpu Penryn-v1

  Using "-cpu pentium2" saw the same high host cpu usage.

  
  My Info:
  M1 MacBook Air
  Mac OS 11.1
  qemu-system-i386 version 5.2 (1ba089f2255bfdb071be3ce6ac6c3069e8012179)
  Windows XP SP3 Build 2600

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1914667/+subscriptions



[Bug 1914294] [NEW] Windows XP displays black screen when smp option is used

2021-02-02 Thread John Arbuckle
Public bug reported:

When I use Windows XP with the -smp option, the screen goes black. The
only thing I can see is a cursor. I have tried -smp 2, -smp cores=4, and
-smp cores=2.

My info:

Host:
M1 Mac
Mac OS 11.1
QEMU 5.2 at cf7ca7d5b9faca13f1f8e3ea92cfb2f741eb0c0e.

Guest:
32-bit Windows XP SP3 build 2600.

** Affects: qemu
 Importance: Undecided
 Status: New

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1914294

Title:
  Windows XP displays black screen when smp option is used

Status in QEMU:
  New

Bug description:
  When I use Windows XP with the -smp option, the screen goes black. The
  only thing I can see is a cursor. I have tried -smp 2, -smp cores=4,
  and -smp cores=2.

  My info:

  Host:
  M1 Mac
  Mac OS 11.1
  QEMU 5.2 at cf7ca7d5b9faca13f1f8e3ea92cfb2f741eb0c0e.

  Guest:
  32-bit Windows XP SP3 build 2600.

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1914294/+subscriptions



[PATCH] Set icon for QEMU binary on Mac OS

2021-02-02 Thread John Arbuckle
Before switching the build system over to Meson, an icon was
added to the QEMU binary on Mac OS. This patch adds back that
feature.

Signed-off-by: John Arbuckle 
---
 meson.build | 20 
 1 file changed, 20 insertions(+)

diff --git a/meson.build b/meson.build
index f00b7754fd..7f534f4e75 100644
--- a/meson.build
+++ b/meson.build
@@ -2183,6 +2183,26 @@ foreach target : target_dirs
link_args: link_args,
gui_app: exe['gui'])
 
+# set QEMU's icon on Mac OS
+if targetos == 'darwin'
+newiconpart1 = custom_target('Icon for ' + exe_name + ' - part 1',
+  depends : emulator,
+  input : emulator,
+  output : 'new icon for ' + exe_name + ' - 1',
+  command : ['Rez', '-append',
+   meson.source_root() + '/pc-bios/qemu.rsrc', '-o',
+   meson.current_build_dir() / exe['name']],
+  build_by_default : true)
+
+custom_target('Icon for ' + exe_name + ' - part 2',
+  depends : newiconpart1,
+  input : emulator,
+  output : 'new icon for ' + exe_name + ' - 2',
+  command : ['SetFile', '-a', 'C',
+   meson.current_build_dir() / exe['name']],
+  build_by_default : true)
+endif
+
 if exe_sign
   emulators += {exe['name'] : custom_target(exe['name'],
install: true,
-- 
2.24.3 (Apple Git-128)




[PATCH] Add support for building on ARM Macs

2021-01-28 Thread John Arbuckle
Adds support for building QEMU on ARM-based Macintoshes. 
This patch has been tested on an M1 Mac running Mac OS 11.1
and on a 64-bit x86 Mac running Mac OS 10.12.

Signed-off-by: John Arbuckle 
---
 configure | 49 +++--
 1 file changed, 39 insertions(+), 10 deletions(-)

diff --git a/configure b/configure
index dcc5ea7d63..f6bcd0ecac 100755
--- a/configure
+++ b/configure
@@ -622,13 +622,40 @@ fi
 # the correct CPU with the --cpu option.
 case $targetos in
 Darwin)
-  # on Leopard most of the system is 32-bit, so we have to ask the kernel if 
we can
-  # run 64-bit userspace code.
-  # If the user didn't specify a CPU explicitly and the kernel says this is
-  # 64 bit hw, then assume x86_64. Otherwise fall through to the usual 
detection code.
-  if test -z "$cpu" && test "$(sysctl -n hw.optional.x86_64)" = "1"; then
-cpu="x86_64"
-  fi
+# user specified the target cpu with --cpu
+if test ! -z "$cpu"; then
+echo "Using user-specified cpu target $cpu"
+
+# detect the host cpu
+else
+raw_value=`sysctl -n hw.cputype`
+cpu_arch=$((raw_value & 0xff))
+
+if [[ $"cpu_arch" -eq 12 ]]; then# if ARM
+is_64bit=$((raw_value & 0x0100))
+if [[ "$is_64bit" -gt 1 ]]; then # if 64-bit
+cpu="aarch64"
+else
+cpu="arm"
+fi
+
+elif [[ $"cpu_arch" -eq 7 ]]; then   # if x86
+is_64bit=`sysctl -n hw.cpu64bit_capable`
+if [[ "$is_64bit" -eq 1 ]]; then # if 64-bit
+cpu="x86_64"
+else
+cpu="x86"
+fi
+
+elif [[ $"cpu_arch" -eq 18 ]]; then  # if PowerPC
+# Not sure know how to detect 64-bit PowerPC a.k.a. G5
+cpu="ppc"
+
+else
+echo "Unknown target cpu error"
+fi
+fi
+
   HOST_DSOSUF=".dylib"
   ;;
 SunOS)
@@ -772,10 +799,12 @@ OpenBSD)
 Darwin)
   bsd="yes"
   darwin="yes"
-  if [ "$cpu" = "x86_64" ] ; then
-QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
-QEMU_LDFLAGS="-arch x86_64 $QEMU_LDFLAGS"
+  cpu_arch="$cpu"
+  if [ $cpu == "aarch64" ]; then   # Apple's clang prefers arm64
+cpu_arch="arm64"
   fi
+  QEMU_CFLAGS="-arch $cpu_arch $QEMU_CFLAGS"
+  QEMU_LDFLAGS="-arch $cpu_arch $QEMU_LDFLAGS"
   audio_drv_list="coreaudio try-sdl"
   audio_possible_drivers="coreaudio sdl"
   QEMU_LDFLAGS="-framework CoreFoundation -framework IOKit $QEMU_LDFLAGS"
-- 
2.24.3 (Apple Git-128)




[PATCH v4] Implement the Screamer sound chip for the mac99 machine type

2020-02-17 Thread John Arbuckle
This patch enables the playback of audio on a Mac OS 9 or Mac OS X guest.

Signed-off-by: John Arbuckle 
---
v4 changes:
- Switched to using HWADDR_PRIx in several debug statements.

v3 changes:
- Updated the location of patched code in hw/ppc/kconfig.
- Removed setting the props variable in screamer.c.
- Removed the screamer_properties variable in screamer.c.

v2 changes:
- Fixed a bug that prevented the sampling rate from being changed.

 hw/audio/Kconfig  |   3 +
 hw/audio/Makefile.objs|   2 +
 hw/audio/screamer.c   | 985 ++
 hw/misc/macio/macio.c |  35 +-
 hw/ppc/Kconfig|   1 +
 hw/ppc/mac.h  |   5 +
 include/hw/audio/screamer.h   |  42 ++
 include/hw/misc/macio/macio.h |   2 +
 8 files changed, 1074 insertions(+), 1 deletion(-)
 create mode 100644 hw/audio/screamer.c
 create mode 100644 include/hw/audio/screamer.h

diff --git a/hw/audio/Kconfig b/hw/audio/Kconfig
index e9c6fed826..196da6c3fe 100644
--- a/hw/audio/Kconfig
+++ b/hw/audio/Kconfig
@@ -50,3 +50,6 @@ config CS4231
 
 config MARVELL_88W8618
 bool
+
+config SCREAMER
+bool
diff --git a/hw/audio/Makefile.objs b/hw/audio/Makefile.objs
index 63db383709..55906886bc 100644
--- a/hw/audio/Makefile.objs
+++ b/hw/audio/Makefile.objs
@@ -15,4 +15,6 @@ common-obj-$(CONFIG_CS4231) += cs4231.o
 common-obj-$(CONFIG_MARVELL_88W8618) += marvell_88w8618.o
 common-obj-$(CONFIG_MILKYMIST) += milkymist-ac97.o
 
+common-obj-$(CONFIG_SCREAMER) += screamer.o
+
 common-obj-y += soundhw.o
diff --git a/hw/audio/screamer.c b/hw/audio/screamer.c
new file mode 100644
index 00..7de17fe8a6
--- /dev/null
+++ b/hw/audio/screamer.c
@@ -0,0 +1,985 @@
+/*
+ * File: Screamer.c
+ * Description: Implement the Screamer sound chip used in Apple Macintoshes.
+ * It works by filling a buffer, then playing the buffer.
+ */
+
+#include "qemu/osdep.h"
+#include "audio/audio.h"
+#include "hw/hw.h"
+#include "hw/irq.h"
+#include 
+#include "hw/ppc/mac.h"
+#include "hw/qdev-properties.h"
+#include "migration/vmstate.h"
+#include "include/hw/audio/screamer.h"
+
+#define DEBUG_SCREAMER 0
+#define DPRINTF(fmt, ...) \
+do { if (DEBUG_SCREAMER) { printf(fmt , ## __VA_ARGS__); } } while (0)
+
+#define SOUND_CONTROL_REG  0
+#define CODEC_CONTROL_REG  1
+#define CODEC_STATUS_REG   2
+#define CLIP_COUNT_REG 3
+#define BYTE_SWAP_REG  4
+#define FRAME_COUNT_REG5
+
+#define AWACS_BUSY 0x0100
+
+/* Used with AWACS register 1 */
+#define RECALIBRATE 0x004
+#define LOOPTHRU0x040
+#define SPEAKER_MUTE0x080
+#define HEADPHONE_MUTE  0x200
+#define OUTPUT_ZERO 0x400
+#define OUTPUT_ONE  0x800
+#define PARALLEL_OUTPUT 0xc00
+
+/* Function prototypes */
+static uint32_t set_busy_bit(uint32_t value, int bit);
+static uint32_t set_part_ready_bit(uint32_t value, int bit_value);
+static uint32_t set_revision(uint32_t input_value);
+static uint32_t set_manufacturer(uint32_t input_value);
+static int get_sampling_rate(ScreamerState *s);
+static uint32_t get_frame_count_reg(ScreamerState *s);
+static void add_to_speaker_buffer(DBDMA_io *io);
+static void dma_request(DBDMA_io *io);
+
+
+/ Getters */
+
+/* Returns the codec control register's encoded AWACS address */
+static uint8_t get_codec_control_address(uint32_t value)
+{
+uint8_t return_value;
+return_value = (value >> 12) & 0x0fff;
+return return_value;
+}
+
+
+static uint32_t get_sound_control_reg(ScreamerState *s)
+{
+DPRINTF("%s() called - returned 0x%x\n", __func__, s->sound_control);
+return s->sound_control;
+}
+
+/* The AWACS registers are accessed thru this register */
+static uint32_t get_codec_control_reg(ScreamerState *s)
+{
+int awacs_register = get_codec_control_address(s->codec_control);
+uint32_t return_value = s->awacs[awacs_register];
+return_value = set_busy_bit(return_value, 0); /* Tell CPU we are ready */
+DPRINTF("%s() called - returned 0x%x\tAWACS register: %d\n", __func__,
+return_value, awacs_register);
+return return_value;
+}
+
+/*
+ * Determines if the readback bit is set.
+ * It is used by the Codec Control register.
+ */
+static bool readback_enabled(ScreamerState *s)
+{
+/* Note: bit zero is the readback enabled bit */
+if (s->awacs[7] & 1) {
+return true;
+} else {
+return false;
+}
+}
+
+static uint32_t get_codec_status_reg(ScreamerState *s)
+{
+uint32_t return_value;
+
+/* if in readback mode - return AWACS register value */
+if (readback_enabled(s)) {
+int awacs_register = (s->awacs[7] & 0xe) >> 1;
+s->awacs[7] = s->awacs[7] & 0xfffe; /* turn off readback mode */
+return_value = s->awacs[awacs

[PATCH v3] Implement the Screamer sound chip for the mac99 machine type

2020-02-16 Thread John Arbuckle
Signed-off-by: John Arbuckle 
---
v3 changes:
- Updated the location of patched code in hw/ppc/kconfig.
- Removed setting the props variable in screamer.c.
- Removed the screamer_properties variable in screamer.c.

v2 changes:
- Fixed a bug that prevented the sampling rate from being changed.

 hw/audio/Kconfig  |   3 +
 hw/audio/Makefile.objs|   2 +
 hw/audio/screamer.c   | 983 ++
 hw/misc/macio/macio.c |  35 +-
 hw/ppc/Kconfig|   1 +
 hw/ppc/mac.h  |   5 +
 include/hw/audio/screamer.h   |  42 ++
 include/hw/misc/macio/macio.h |   2 +
 8 files changed, 1072 insertions(+), 1 deletion(-)
 create mode 100644 hw/audio/screamer.c
 create mode 100644 include/hw/audio/screamer.h

diff --git a/hw/audio/Kconfig b/hw/audio/Kconfig
index e9c6fed826..196da6c3fe 100644
--- a/hw/audio/Kconfig
+++ b/hw/audio/Kconfig
@@ -50,3 +50,6 @@ config CS4231
 
 config MARVELL_88W8618
 bool
+
+config SCREAMER
+bool
diff --git a/hw/audio/Makefile.objs b/hw/audio/Makefile.objs
index 63db383709..55906886bc 100644
--- a/hw/audio/Makefile.objs
+++ b/hw/audio/Makefile.objs
@@ -15,4 +15,6 @@ common-obj-$(CONFIG_CS4231) += cs4231.o
 common-obj-$(CONFIG_MARVELL_88W8618) += marvell_88w8618.o
 common-obj-$(CONFIG_MILKYMIST) += milkymist-ac97.o
 
+common-obj-$(CONFIG_SCREAMER) += screamer.o
+
 common-obj-y += soundhw.o
diff --git a/hw/audio/screamer.c b/hw/audio/screamer.c
new file mode 100644
index 00..ad4aba12eb
--- /dev/null
+++ b/hw/audio/screamer.c
@@ -0,0 +1,983 @@
+/*
+ * File: Screamer.c
+ * Description: Implement the Screamer sound chip used in Apple Macintoshes.
+ * It works by filling a buffer, then playing the buffer.
+ */
+
+#include "qemu/osdep.h"
+#include "audio/audio.h"
+#include "hw/hw.h"
+#include "hw/irq.h"
+#include 
+#include "hw/ppc/mac.h"
+#include "hw/qdev-properties.h"
+#include "migration/vmstate.h"
+#include "include/hw/audio/screamer.h"
+
+#define DEBUG_SCREAMER 0
+#define DPRINTF(fmt, ...) \
+do { if (DEBUG_SCREAMER) { printf(fmt , ## __VA_ARGS__); } } while (0)
+
+#define SOUND_CONTROL_REG  0
+#define CODEC_CONTROL_REG  1
+#define CODEC_STATUS_REG   2
+#define CLIP_COUNT_REG 3
+#define BYTE_SWAP_REG  4
+#define FRAME_COUNT_REG5
+
+#define AWACS_BUSY 0x0100
+
+/* Used with AWACS register 1 */
+#define RECALIBRATE 0x004
+#define LOOPTHRU0x040
+#define SPEAKER_MUTE0x080
+#define HEADPHONE_MUTE  0x200
+#define OUTPUT_ZERO 0x400
+#define OUTPUT_ONE  0x800
+#define PARALLEL_OUTPUT 0xc00
+
+/* Function prototypes */
+static uint32_t set_busy_bit(uint32_t value, int bit);
+static uint32_t set_part_ready_bit(uint32_t value, int bit_value);
+static uint32_t set_revision(uint32_t input_value);
+static uint32_t set_manufacturer(uint32_t input_value);
+static int get_sampling_rate(ScreamerState *s);
+static uint32_t get_frame_count_reg(ScreamerState *s);
+static void add_to_speaker_buffer(DBDMA_io *io);
+static void dma_request(DBDMA_io *io);
+
+
+/ Getters */
+
+/* Returns the codec control register's encoded AWACS address */
+static uint8_t get_codec_control_address(uint32_t value)
+{
+uint8_t return_value;
+return_value = (value >> 12) & 0x0fff;
+return return_value;
+}
+
+
+static uint32_t get_sound_control_reg(ScreamerState *s)
+{
+DPRINTF("%s() called - returned 0x%x\n", __func__, s->sound_control);
+return s->sound_control;
+}
+
+/* The AWACS registers are accessed thru this register */
+static uint32_t get_codec_control_reg(ScreamerState *s)
+{
+int awacs_register = get_codec_control_address(s->codec_control);
+uint32_t return_value = s->awacs[awacs_register];
+return_value = set_busy_bit(return_value, 0); /* Tell CPU we are ready */
+DPRINTF("%s() called - returned 0x%x\tAWACS register: %d\n", __func__,
+return_value, awacs_register);
+return return_value;
+}
+
+/*
+ * Determines if the readback bit is set.
+ * It is used by the Codec Control register.
+ */
+static bool readback_enabled(ScreamerState *s)
+{
+/* Note: bit zero is the readback enabled bit */
+if (s->awacs[7] & 1) {
+return true;
+} else {
+return false;
+}
+}
+
+static uint32_t get_codec_status_reg(ScreamerState *s)
+{
+uint32_t return_value;
+
+/* if in readback mode - return AWACS register value */
+if (readback_enabled(s)) {
+int awacs_register = (s->awacs[7] & 0xe) >> 1;
+s->awacs[7] = s->awacs[7] & 0xfffe; /* turn off readback mode */
+return_value = s->awacs[awacs_register] << 4;
+DPRINTF("readback enable bit is set, returning AWACS register %d\t"
+"value:0x%x\n", awacs_

Ping: [PATCH v2] Implement the Screamer sound chip for the mac99 machine type

2020-01-12 Thread John Arbuckle
Ping

https://patchwork.kernel.org/patch/11311763/

This patch enables the playback of audio on a Mac OS 9 or Mac OS X guest.

Signed-off-by: John Arbuckle 
---
v2 changes:
- Fixed a bug that prevented the sampling rate from being changed.

 hw/audio/Kconfig  |   3 +
 hw/audio/Makefile.objs|   2 +
 hw/audio/screamer.c   | 993 ++
 hw/misc/macio/macio.c |  35 +-
 hw/ppc/Kconfig|   1 +
 hw/ppc/mac.h  |   5 +
 include/hw/audio/screamer.h   |  42 ++
 include/hw/misc/macio/macio.h |   2 +
 8 files changed, 1082 insertions(+), 1 deletion(-)
 create mode 100644 hw/audio/screamer.c
 create mode 100644 include/hw/audio/screamer.h

diff --git a/hw/audio/Kconfig b/hw/audio/Kconfig
index e9c6fed826..196da6c3fe 100644
--- a/hw/audio/Kconfig
+++ b/hw/audio/Kconfig
@@ -50,3 +50,6 @@ config CS4231
 
 config MARVELL_88W8618
 bool
+
+config SCREAMER
+bool
diff --git a/hw/audio/Makefile.objs b/hw/audio/Makefile.objs
index 63db383709..55906886bc 100644
--- a/hw/audio/Makefile.objs
+++ b/hw/audio/Makefile.objs
@@ -15,4 +15,6 @@ common-obj-$(CONFIG_CS4231) += cs4231.o
 common-obj-$(CONFIG_MARVELL_88W8618) += marvell_88w8618.o
 common-obj-$(CONFIG_MILKYMIST) += milkymist-ac97.o
 
+common-obj-$(CONFIG_SCREAMER) += screamer.o
+
 common-obj-y += soundhw.o
diff --git a/hw/audio/screamer.c b/hw/audio/screamer.c
new file mode 100644
index 00..d3a86d2e67
--- /dev/null
+++ b/hw/audio/screamer.c
@@ -0,0 +1,993 @@
+/*
+ * File: Screamer.c
+ * Description: Implement the Screamer sound chip used in Apple Macintoshes.
+ * It works by filling a buffer, then playing the buffer.
+ */
+
+#include "qemu/osdep.h"
+#include "audio/audio.h"
+#include "hw/hw.h"
+#include "hw/irq.h"
+#include 
+#include "hw/ppc/mac.h"
+#include "hw/qdev-properties.h"
+#include "migration/vmstate.h"
+#include "include/hw/audio/screamer.h"
+
+#define DEBUG_SCREAMER 0
+#define DPRINTF(fmt, ...) \
+do { if (DEBUG_SCREAMER) { printf(fmt , ## __VA_ARGS__); } } while (0)
+
+#define SOUND_CONTROL_REG  0
+#define CODEC_CONTROL_REG  1
+#define CODEC_STATUS_REG   2
+#define CLIP_COUNT_REG 3
+#define BYTE_SWAP_REG  4
+#define FRAME_COUNT_REG5
+
+#define AWACS_BUSY 0x0100
+
+/* Used with AWACS register 1 */
+#define RECALIBRATE 0x004
+#define LOOPTHRU0x040
+#define SPEAKER_MUTE0x080
+#define HEADPHONE_MUTE  0x200
+#define OUTPUT_ZERO 0x400
+#define OUTPUT_ONE  0x800
+#define PARALLEL_OUTPUT 0xc00
+
+/* Function prototypes */
+static uint32_t set_busy_bit(uint32_t value, int bit);
+static uint32_t set_part_ready_bit(uint32_t value, int bit_value);
+static uint32_t set_revision(uint32_t input_value);
+static uint32_t set_manufacturer(uint32_t input_value);
+static int get_sampling_rate(ScreamerState *s);
+static uint32_t get_frame_count_reg(ScreamerState *s);
+static void add_to_speaker_buffer(DBDMA_io *io);
+static void dma_request(DBDMA_io *io);
+
+
+/ Getters */
+
+/* Returns the codec control register's encoded AWACS address */
+static uint8_t get_codec_control_address(uint32_t value)
+{
+uint8_t return_value;
+return_value = (value >> 12) & 0x0fff;
+return return_value;
+}
+
+
+static uint32_t get_sound_control_reg(ScreamerState *s)
+{
+DPRINTF("%s() called - returned 0x%x\n", __func__, s->sound_control);
+return s->sound_control;
+}
+
+/* The AWACS registers are accessed thru this register */
+static uint32_t get_codec_control_reg(ScreamerState *s)
+{
+int awacs_register = get_codec_control_address(s->codec_control);
+uint32_t return_value = s->awacs[awacs_register];
+return_value = set_busy_bit(return_value, 0); /* Tell CPU we are ready */
+DPRINTF("%s() called - returned 0x%x\tAWACS register: %d\n", __func__,
+return_value, awacs_register);
+return return_value;
+}
+
+/*
+ * Determines if the readback bit is set.
+ * It is used by the Codec Control register.
+ */
+static bool readback_enabled(ScreamerState *s)
+{
+/* Note: bit zero is the readback enabled bit */
+if (s->awacs[7] & 1) {
+return true;
+} else {
+return false;
+}
+}
+
+static uint32_t get_codec_status_reg(ScreamerState *s)
+{
+uint32_t return_value;
+
+/* if in readback mode - return AWACS register value */
+if (readback_enabled(s)) {
+int awacs_register = (s->awacs[7] & 0xe) >> 1;
+s->awacs[7] = s->awacs[7] & 0xfffe; /* turn off readback mode */
+return_value = s->awacs[awacs_register] << 4;
+DPRINTF("readback enable bit is set, returning AWACS register %d\t"
+"value:0x%x\n", awacs_register, return_value);
+
+return retur

[Bug 1859081] Re: Mouse way too fast when Qemu is on a Windows VM with a OS 9 Guest

2020-01-09 Thread John Arbuckle
What is the QEMU command-line you use?
Does this problem exist with the usb mouse (-device usb-mouse)?
Could you try upgrading to the latest version of QEMU and see if the issue is 
resolved please?

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1859081

Title:
  Mouse way too fast when Qemu is on a Windows VM with a OS 9 Guest

Status in QEMU:
  New

Bug description:
  On a server, I have a Windows 10 VM with Qemu 4.1.0 (latest) from 
https://qemu.weilnetz.de/w64/ installed.
  There I have a Mac OS 9.2.2 machine.
  Now if I connect to the Windows VM with VNC or RDP or even VMWare console, 
the Mouse in the Mac OS Guest inside Qemu is wy to fast. Even when lowering 
the mouse speed in the Mac OS mouse setting, one pixel in the Host (Windows 10 
VM) still moves the mouse by 10 pixels inside the Qemu machine.
  I tried different resolutions but that does not help.
  Is there any way to fix this or any way how I can provide more information?
  Thanks

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1859081/+subscriptions



[PATCH v2] Implement the Screamer sound chip for the mac99 machine type

2019-12-28 Thread John Arbuckle
This patch enables the playback of audio on a Mac OS 9 or Mac OS X guest.

Signed-off-by: John Arbuckle 
---
v2 changes:
- Fixed a bug that prevented the sampling rate from being changed.

 hw/audio/Kconfig  |   3 +
 hw/audio/Makefile.objs|   2 +
 hw/audio/screamer.c   | 993 ++
 hw/misc/macio/macio.c |  35 +-
 hw/ppc/Kconfig|   1 +
 hw/ppc/mac.h  |   5 +
 include/hw/audio/screamer.h   |  42 ++
 include/hw/misc/macio/macio.h |   2 +
 8 files changed, 1082 insertions(+), 1 deletion(-)
 create mode 100644 hw/audio/screamer.c
 create mode 100644 include/hw/audio/screamer.h

diff --git a/hw/audio/Kconfig b/hw/audio/Kconfig
index e9c6fed826..196da6c3fe 100644
--- a/hw/audio/Kconfig
+++ b/hw/audio/Kconfig
@@ -50,3 +50,6 @@ config CS4231
 
 config MARVELL_88W8618
 bool
+
+config SCREAMER
+bool
diff --git a/hw/audio/Makefile.objs b/hw/audio/Makefile.objs
index 63db383709..55906886bc 100644
--- a/hw/audio/Makefile.objs
+++ b/hw/audio/Makefile.objs
@@ -15,4 +15,6 @@ common-obj-$(CONFIG_CS4231) += cs4231.o
 common-obj-$(CONFIG_MARVELL_88W8618) += marvell_88w8618.o
 common-obj-$(CONFIG_MILKYMIST) += milkymist-ac97.o
 
+common-obj-$(CONFIG_SCREAMER) += screamer.o
+
 common-obj-y += soundhw.o
diff --git a/hw/audio/screamer.c b/hw/audio/screamer.c
new file mode 100644
index 00..d3a86d2e67
--- /dev/null
+++ b/hw/audio/screamer.c
@@ -0,0 +1,993 @@
+/*
+ * File: Screamer.c
+ * Description: Implement the Screamer sound chip used in Apple Macintoshes.
+ * It works by filling a buffer, then playing the buffer.
+ */
+
+#include "qemu/osdep.h"
+#include "audio/audio.h"
+#include "hw/hw.h"
+#include "hw/irq.h"
+#include 
+#include "hw/ppc/mac.h"
+#include "hw/qdev-properties.h"
+#include "migration/vmstate.h"
+#include "include/hw/audio/screamer.h"
+
+#define DEBUG_SCREAMER 0
+#define DPRINTF(fmt, ...) \
+do { if (DEBUG_SCREAMER) { printf(fmt , ## __VA_ARGS__); } } while (0)
+
+#define SOUND_CONTROL_REG  0
+#define CODEC_CONTROL_REG  1
+#define CODEC_STATUS_REG   2
+#define CLIP_COUNT_REG 3
+#define BYTE_SWAP_REG  4
+#define FRAME_COUNT_REG5
+
+#define AWACS_BUSY 0x0100
+
+/* Used with AWACS register 1 */
+#define RECALIBRATE 0x004
+#define LOOPTHRU0x040
+#define SPEAKER_MUTE0x080
+#define HEADPHONE_MUTE  0x200
+#define OUTPUT_ZERO 0x400
+#define OUTPUT_ONE  0x800
+#define PARALLEL_OUTPUT 0xc00
+
+/* Function prototypes */
+static uint32_t set_busy_bit(uint32_t value, int bit);
+static uint32_t set_part_ready_bit(uint32_t value, int bit_value);
+static uint32_t set_revision(uint32_t input_value);
+static uint32_t set_manufacturer(uint32_t input_value);
+static int get_sampling_rate(ScreamerState *s);
+static uint32_t get_frame_count_reg(ScreamerState *s);
+static void add_to_speaker_buffer(DBDMA_io *io);
+static void dma_request(DBDMA_io *io);
+
+
+/ Getters */
+
+/* Returns the codec control register's encoded AWACS address */
+static uint8_t get_codec_control_address(uint32_t value)
+{
+uint8_t return_value;
+return_value = (value >> 12) & 0x0fff;
+return return_value;
+}
+
+
+static uint32_t get_sound_control_reg(ScreamerState *s)
+{
+DPRINTF("%s() called - returned 0x%x\n", __func__, s->sound_control);
+return s->sound_control;
+}
+
+/* The AWACS registers are accessed thru this register */
+static uint32_t get_codec_control_reg(ScreamerState *s)
+{
+int awacs_register = get_codec_control_address(s->codec_control);
+uint32_t return_value = s->awacs[awacs_register];
+return_value = set_busy_bit(return_value, 0); /* Tell CPU we are ready */
+DPRINTF("%s() called - returned 0x%x\tAWACS register: %d\n", __func__,
+return_value, awacs_register);
+return return_value;
+}
+
+/*
+ * Determines if the readback bit is set.
+ * It is used by the Codec Control register.
+ */
+static bool readback_enabled(ScreamerState *s)
+{
+/* Note: bit zero is the readback enabled bit */
+if (s->awacs[7] & 1) {
+return true;
+} else {
+return false;
+}
+}
+
+static uint32_t get_codec_status_reg(ScreamerState *s)
+{
+uint32_t return_value;
+
+/* if in readback mode - return AWACS register value */
+if (readback_enabled(s)) {
+int awacs_register = (s->awacs[7] & 0xe) >> 1;
+s->awacs[7] = s->awacs[7] & 0xfffe; /* turn off readback mode */
+return_value = s->awacs[awacs_register] << 4;
+DPRINTF("readback enable bit is set, returning AWACS register %d\t"
+"value:0x%x\n", awacs_register, return_value);
+
+return return_value;
+}
+
+/* Tell CPU we are ready */
+r

[PATCH] Implement the Screamer sound chip for the mac99 machine type

2019-12-21 Thread John Arbuckle
This patch enables the playback of audio on a Mac OS 9 or Mac OS X guest.

Signed-off-by: John Arbuckle 
---
 hw/audio/Kconfig  |   3 +
 hw/audio/Makefile.objs|   2 +
 hw/audio/screamer.c   | 992 ++
 hw/misc/macio/macio.c |  35 +-
 hw/ppc/Kconfig|   1 +
 hw/ppc/mac.h  |   5 +
 include/hw/audio/screamer.h   |  42 ++
 include/hw/misc/macio/macio.h |   2 +
 8 files changed, 1081 insertions(+), 1 deletion(-)
 create mode 100644 hw/audio/screamer.c
 create mode 100644 include/hw/audio/screamer.h

diff --git a/hw/audio/Kconfig b/hw/audio/Kconfig
index e9c6fed826..196da6c3fe 100644
--- a/hw/audio/Kconfig
+++ b/hw/audio/Kconfig
@@ -50,3 +50,6 @@ config CS4231
 
 config MARVELL_88W8618
 bool
+
+config SCREAMER
+bool
diff --git a/hw/audio/Makefile.objs b/hw/audio/Makefile.objs
index 63db383709..55906886bc 100644
--- a/hw/audio/Makefile.objs
+++ b/hw/audio/Makefile.objs
@@ -15,4 +15,6 @@ common-obj-$(CONFIG_CS4231) += cs4231.o
 common-obj-$(CONFIG_MARVELL_88W8618) += marvell_88w8618.o
 common-obj-$(CONFIG_MILKYMIST) += milkymist-ac97.o
 
+common-obj-$(CONFIG_SCREAMER) += screamer.o
+
 common-obj-y += soundhw.o
diff --git a/hw/audio/screamer.c b/hw/audio/screamer.c
new file mode 100644
index 00..c1d75b14cf
--- /dev/null
+++ b/hw/audio/screamer.c
@@ -0,0 +1,992 @@
+/*
+ * File: Screamer.c
+ * Description: Implement the Screamer sound chip used in Apple Macintoshes.
+ * It works by filling a buffer, then playing the buffer.
+ */
+
+#include "qemu/osdep.h"
+#include "audio/audio.h"
+#include "hw/hw.h"
+#include "hw/irq.h"
+#include 
+#include "hw/ppc/mac.h"
+#include "hw/qdev-properties.h"
+#include "migration/vmstate.h"
+#include "include/hw/audio/screamer.h"
+
+#define DEBUG_SCREAMER 0
+#define DPRINTF(fmt, ...) \
+do { if (DEBUG_SCREAMER) { printf(fmt , ## __VA_ARGS__); } } while (0)
+
+#define SOUND_CONTROL_REG  0
+#define CODEC_CONTROL_REG  1
+#define CODEC_STATUS_REG   2
+#define CLIP_COUNT_REG 3
+#define BYTE_SWAP_REG  4
+#define FRAME_COUNT_REG5
+
+#define AWACS_BUSY 0x0100
+
+/* Used with AWACS register 1 */
+#define RECALIBRATE 0x004
+#define LOOPTHRU0x040
+#define SPEAKER_MUTE0x080
+#define HEADPHONE_MUTE  0x200
+#define OUTPUT_ZERO 0x400
+#define OUTPUT_ONE  0x800
+#define PARALLEL_OUTPUT 0xc00
+
+/* Function prototypes */
+static uint32_t set_busy_bit(uint32_t value, int bit);
+static uint32_t set_part_ready_bit(uint32_t value, int bit_value);
+static uint32_t set_revision(uint32_t input_value);
+static uint32_t set_manufacturer(uint32_t input_value);
+static int get_sampling_rate(ScreamerState *s);
+static uint32_t get_frame_count_reg(ScreamerState *s);
+static void add_to_speaker_buffer(DBDMA_io *io);
+static void dma_request(DBDMA_io *io);
+
+
+/ Getters */
+
+/* Returns the codec control register's encoded AWACS address */
+static uint8_t get_codec_control_address(uint32_t value)
+{
+uint8_t return_value;
+return_value = (value >> 12) & 0x0fff;
+return return_value;
+}
+
+
+static uint32_t get_sound_control_reg(ScreamerState *s)
+{
+DPRINTF("%s() called - returned 0x%x\n", __func__, s->sound_control);
+return s->sound_control;
+}
+
+/* The AWACS registers are accessed thru this register */
+static uint32_t get_codec_control_reg(ScreamerState *s)
+{
+int awacs_register = get_codec_control_address(s->codec_control);
+uint32_t return_value = s->awacs[awacs_register];
+return_value = set_busy_bit(return_value, 0); /* Tell CPU we are ready */
+DPRINTF("%s() called - returned 0x%x\tAWACS register: %d\n", __func__,
+return_value, awacs_register);
+return return_value;
+}
+
+/*
+ * Determines if the readback bit is set.
+ * It is used by the Codec Control register.
+ */
+static bool readback_enabled(ScreamerState *s)
+{
+/* Note: bit zero is the readback enabled bit */
+if (s->awacs[7] & 1) {
+return true;
+} else {
+return false;
+}
+}
+
+static uint32_t get_codec_status_reg(ScreamerState *s)
+{
+uint32_t return_value;
+
+/* if in readback mode - return AWACS register value */
+if (readback_enabled(s)) {
+int awacs_register = (s->awacs[7] & 0xe) >> 1;
+s->awacs[7] = s->awacs[7] & 0xfffe; /* turn off readback mode */
+return_value = s->awacs[awacs_register] << 4;
+DPRINTF("readback enable bit is set, returning AWACS register %d\t"
+"value:0x%x\n", awacs_register, return_value);
+
+return return_value;
+}
+
+/* Tell CPU we are ready */
+return_value = set_part_ready_bit(s->codec_status, 1);
+
+/* Set Revision t

Re: [Bug 1623998] Re: pulseaudio Invalid argument error

2019-10-07 Thread John Arbuckle
Here is the output. I assumed you meant qemu-system-ppc.

$ ./ppc-softmmu/qemu-system-ppc -audio-help
Environment variable based configuration deprecated.
Please use the new -audiodev option.

Equivalent -audiodev to your current environment variables:
(Since you didn't specify QEMU_AUDIO_DRV, I'll list all possibilities)
-audiodev id=oss,driver=oss
-audiodev id=none,driver=none

> On Oct 7, 2019, at 3:44 AM, Thomas Huth <1623...@bugs.launchpad.net> wrote:
> 
> What output do you get when you run "qemu-system-x86_64 -audio-help" ?
> Could you provide your full command line, please?
> 
> -- 
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1623998
> 
> Title:
>  pulseaudio Invalid argument error
> 
> Status in QEMU:
>  Incomplete
> 
> Bug description:
>  When using qemu-system-ppc on Ubuntu Mate 15 with the usb audio card,
>  I see these error messages:
> 
>  pulseaudio: set_sink_input_volume() failed
>  pulseaudio: Reason: Invalid argument
>  pulseaudio: set_sink_input_mute() failed
>  pulseaudio: Reason: Invalid argument
> 
>  No audio plays. When an attempt is made, QEMU seems to freeze for a
>  moment.
> 
>  I use "-device usb-audio" to add the usb sound card. This issue is
>  present in both emulation and KVM mode.
> 
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/qemu/+bug/1623998/+subscriptions

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1623998

Title:
  pulseaudio Invalid argument error

Status in QEMU:
  Incomplete

Bug description:
  When using qemu-system-ppc on Ubuntu Mate 15 with the usb audio card,
  I see these error messages:

  pulseaudio: set_sink_input_volume() failed
  pulseaudio: Reason: Invalid argument
  pulseaudio: set_sink_input_mute() failed
  pulseaudio: Reason: Invalid argument

  No audio plays. When an attempt is made, QEMU seems to freeze for a
  moment.

  I use "-device usb-audio" to add the usb sound card. This issue is
  present in both emulation and KVM mode.

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1623998/+subscriptions



[Bug 1623998] Re: pulseaudio Invalid argument error

2019-10-04 Thread John Arbuckle
I tried using "-device usb-audio"and the guest was able to detect the
USB audio card, but for some reason no audio would play. I did not see
any messages in the terminal about pulseaudio.

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1623998

Title:
  pulseaudio Invalid argument error

Status in QEMU:
  Incomplete

Bug description:
  When using qemu-system-ppc on Ubuntu Mate 15 with the usb audio card,
  I see these error messages:

  pulseaudio: set_sink_input_volume() failed
  pulseaudio: Reason: Invalid argument
  pulseaudio: set_sink_input_mute() failed
  pulseaudio: Reason: Invalid argument

  No audio plays. When an attempt is made, QEMU seems to freeze for a
  moment.

  I use "-device usb-audio" to add the usb sound card. This issue is
  present in both emulation and KVM mode.

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1623998/+subscriptions



[Qemu-devel] [PATCH 1/2] Implement Floating Point flag Fraction Rounded

2019-05-24 Thread John Arbuckle
Signed-off-by: John Arbuckle 
---
 fpu/softfloat.c   | 15 ---
 include/fpu/softfloat-types.h |  1 +
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/fpu/softfloat.c b/fpu/softfloat.c
index 2ba36ec370..ac34f6a2de 100644
--- a/fpu/softfloat.c
+++ b/fpu/softfloat.c
@@ -702,7 +702,7 @@ static FloatParts round_canonical(FloatParts p, 
float_status *s,
 const uint64_t roundeven_mask = parm->roundeven_mask;
 const int exp_max = parm->exp_max;
 const int frac_shift = parm->frac_shift;
-uint64_t frac, inc;
+uint64_t frac, inc, rounded;
 int exp, flags = 0;
 bool overflow_norm;
 
@@ -744,7 +744,12 @@ static FloatParts round_canonical(FloatParts p, 
float_status *s,
 if (likely(exp > 0)) {
 if (frac & round_mask) {
 flags |= float_flag_inexact;
-frac += inc;
+rounded = frac + inc;
+if ((rounded ^ frac) & frac_lsb) {
+flags |= float_flag_rounded;
+}
+frac = rounded;
+
 if (frac & DECOMPOSED_OVERFLOW_BIT) {
 frac >>= 1;
 exp++;
@@ -793,7 +798,11 @@ static FloatParts round_canonical(FloatParts p, 
float_status *s,
 break;
 }
 flags |= float_flag_inexact;
-frac += inc;
+rounded = frac + inc;
+if ((rounded ^ frac) & frac_lsb) {
+flags |= float_flag_rounded;
+}
+frac = rounded;
 }
 
 exp = (frac & DECOMPOSED_IMPLICIT_BIT ? 1 : 0);
diff --git a/include/fpu/softfloat-types.h b/include/fpu/softfloat-types.h
index 2aae6a89b1..bee576e0fd 100644
--- a/include/fpu/softfloat-types.h
+++ b/include/fpu/softfloat-types.h
@@ -147,6 +147,7 @@ enum {
 
 enum {
 float_flag_invalid   =  1,
+float_flag_rounded   =  2,
 float_flag_divbyzero =  4,
 float_flag_overflow  =  8,
 float_flag_underflow = 16,
-- 
2.14.3 (Apple Git-98)




[Qemu-devel] [PATCH 0/2] Implement PowerPC FPSCR flag Fraction Rounded

2019-05-24 Thread John Arbuckle
In IEEE 754 math, the arithmetic, rounding, and conversion instructions produce 
an intermediate result that can be regarded as having infinite precision and 
unbounded exponent range. When the final result has its fraction part 
incremented is when the Fraction Rounded bit is set.

This patch implements the PowerPC FPSCR flag Fraction Rounded.

Note: there are still functions in softfloat that need to be adjusted so that 
float_flag_rounded is fully supported. These include round_to_int(), and all 
legacy roundAndPack* functions. So basically anywhere that sets the 
float_flag_inexact.

John Arbuckle (2):
  Implement Floating Point flag Fraction Rounded
  Implement the PowerPC Floating Point Status and Control Register
Fraction Rounded bit

 fpu/softfloat.c   | 15 ---
 include/fpu/softfloat-types.h |  1 +
 target/ppc/fpu_helper.c   |  4 
 3 files changed, 17 insertions(+), 3 deletions(-)

-- 
2.14.3 (Apple Git-98)




[Qemu-devel] [PATCH 2/2] Implement the PowerPC Floating Point Status and Control Register Fraction Rounded bit

2019-05-24 Thread John Arbuckle
Signed-off-by: John Arbuckle 
---
 target/ppc/fpu_helper.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/target/ppc/fpu_helper.c b/target/ppc/fpu_helper.c
index 0b7308f539..0baf1ce8e4 100644
--- a/target/ppc/fpu_helper.c
+++ b/target/ppc/fpu_helper.c
@@ -630,6 +630,10 @@ static void do_float_check_status(CPUPPCState *env, 
uintptr_t raddr)
 env->fpscr &= ~(1 << FPSCR_FI); /* clear the FPSCR[FI] bit */
 }
 
+/* Set or clear the Fraction Rounded bit */
+env->fpscr = deposit32(env->fpscr, FPSCR_FR, 1,
+   (status & float_flag_rounded) != 0);
+
 if (cs->exception_index == POWERPC_EXCP_PROGRAM &&
 (env->error_code & POWERPC_EXCP_FP)) {
 /* Differred floating-point exception after target FPR update */
-- 
2.14.3 (Apple Git-98)




[Qemu-devel] [PATCH] Implement Fraction Rounded bit in FPSCR for PowerPC

2019-05-21 Thread John Arbuckle
Implement the PowerPC floating point status and control register flag Fraction 
Rounded.

Signed-off-by: John Arbuckle 
---
 fpu/softfloat.c   | 15 ---
 include/fpu/softfloat-types.h |  1 +
 target/ppc/fpu_helper.c   |  4 
 3 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/fpu/softfloat.c b/fpu/softfloat.c
index 2ba36ec370..ac34f6a2de 100644
--- a/fpu/softfloat.c
+++ b/fpu/softfloat.c
@@ -702,7 +702,7 @@ static FloatParts round_canonical(FloatParts p, 
float_status *s,
 const uint64_t roundeven_mask = parm->roundeven_mask;
 const int exp_max = parm->exp_max;
 const int frac_shift = parm->frac_shift;
-uint64_t frac, inc;
+uint64_t frac, inc, rounded;
 int exp, flags = 0;
 bool overflow_norm;
 
@@ -744,7 +744,12 @@ static FloatParts round_canonical(FloatParts p, 
float_status *s,
 if (likely(exp > 0)) {
 if (frac & round_mask) {
 flags |= float_flag_inexact;
-frac += inc;
+rounded = frac + inc;
+if ((rounded ^ frac) & frac_lsb) {
+flags |= float_flag_rounded;
+}
+frac = rounded;
+
 if (frac & DECOMPOSED_OVERFLOW_BIT) {
 frac >>= 1;
 exp++;
@@ -793,7 +798,11 @@ static FloatParts round_canonical(FloatParts p, 
float_status *s,
 break;
 }
 flags |= float_flag_inexact;
-frac += inc;
+rounded = frac + inc;
+if ((rounded ^ frac) & frac_lsb) {
+flags |= float_flag_rounded;
+}
+frac = rounded;
 }
 
 exp = (frac & DECOMPOSED_IMPLICIT_BIT ? 1 : 0);
diff --git a/include/fpu/softfloat-types.h b/include/fpu/softfloat-types.h
index 2aae6a89b1..bee576e0fd 100644
--- a/include/fpu/softfloat-types.h
+++ b/include/fpu/softfloat-types.h
@@ -147,6 +147,7 @@ enum {
 
 enum {
 float_flag_invalid   =  1,
+float_flag_rounded   =  2,
 float_flag_divbyzero =  4,
 float_flag_overflow  =  8,
 float_flag_underflow = 16,
diff --git a/target/ppc/fpu_helper.c b/target/ppc/fpu_helper.c
index 0b7308f539..0baf1ce8e4 100644
--- a/target/ppc/fpu_helper.c
+++ b/target/ppc/fpu_helper.c
@@ -630,6 +630,10 @@ static void do_float_check_status(CPUPPCState *env, 
uintptr_t raddr)
 env->fpscr &= ~(1 << FPSCR_FI); /* clear the FPSCR[FI] bit */
 }
 
+/* Set or clear the Fraction Rounded bit */
+env->fpscr = deposit32(env->fpscr, FPSCR_FR, 1,
+   (status & float_flag_rounded) != 0);
+
 if (cs->exception_index == POWERPC_EXCP_PROGRAM &&
 (env->error_code & POWERPC_EXCP_FP)) {
 /* Differred floating-point exception after target FPR update */
-- 
2.14.3 (Apple Git-98)




[Qemu-devel] [PATCH] configure: Change capstone's default state to disabled

2019-04-18 Thread John Arbuckle
Capstone is not necessary in order to use QEMU. Disable it by default.
This will save the user the pain of having to figure why QEMU isn't
building when this library is missing.

Signed-off-by: John Arbuckle 
---
 configure | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure b/configure
index 1c563a7027..77d7967f92 100755
--- a/configure
+++ b/configure
@@ -433,7 +433,7 @@ opengl_dmabuf="no"
 cpuid_h="no"
 avx2_opt=""
 zlib="yes"
-capstone=""
+capstone="no"
 lzo=""
 snappy=""
 bzip2=""
-- 
2.14.3 (Apple Git-98)




[Qemu-devel] (no subject)

2018-11-27 Thread John Arbuckle
>From af4497f2b161bb4165acb8eee5cae3f2a7ea2227 Mon Sep 17 00:00:00 2001
From: John Arbuckle 
Date: Tue, 27 Nov 2018 20:01:20 -0500
Subject: [PATCH] ui/cocoa.m: fix crash due to cocoa_refresh() on Mac OS 10.14

Mac OS 10.14 only wants UI code to be called from the main thread. The
cocoa_refresh() function is called on another thread and this causes a
crash to take place. To fix this problem the cocoa_refresh() code is
called from the main thread only. 

Signed-off-by: John Arbuckle 
---
 ui/cocoa.m | 59 ++-
 1 file changed, 34 insertions(+), 25 deletions(-)

diff --git a/ui/cocoa.m b/ui/cocoa.m
index ecf12bfc2e..17c168d08f 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -972,6 +972,8 @@ - (void)openDocumentation:(NSString *)filename;
 - (IBAction) do_about_menu_item: (id) sender;
 - (void)make_about_window;
 - (void)adjustSpeed:(id)sender;
+- (void) cocoa_refresh;
+- (void) cocoa_refresh_internal: (id) dummy;
 @end
 
 @implementation QemuCocoaAppController
@@ -1406,6 +1408,37 @@ - (void)adjustSpeed:(id)sender
 COCOA_DEBUG("cpu throttling at %d%c\n", cpu_throttle_get_percentage(), 
'%');
 }
 
+- (void) cocoa_refresh
+{
+[self performSelectorOnMainThread: @selector(cocoa_refresh_internal:) 
withObject: nil waitUntilDone: YES];
+}
+
+- (void) cocoa_refresh_internal: (id) dummy
+{
+COCOA_DEBUG("qemu_cocoa: cocoa_refresh\n");
+graphic_hw_update(NULL);
+
+if (qemu_input_is_absolute()) {
+if (![cocoaView isAbsoluteEnabled]) {
+if ([cocoaView isMouseGrabbed]) {
+[cocoaView ungrabMouse];
+}
+}
+[cocoaView setAbsoluteEnabled:YES];
+}
+
+NSDate *distantPast;
+NSEvent *event;
+distantPast = [NSDate distantPast];
+do {
+event = [NSApp nextEventMatchingMask:NSEventMaskAny 
untilDate:distantPast
+  inMode: NSDefaultRunLoopMode 
dequeue:YES];
+if (event != nil) {
+[cocoaView handleEvent:event];
+}
+} while(event != nil);
+}
+
 @end
 
 
@@ -1579,31 +1612,7 @@ static void cocoa_switch(DisplayChangeListener *dcl,
 
 static void cocoa_refresh(DisplayChangeListener *dcl)
 {
-NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
-
-COCOA_DEBUG("qemu_cocoa: cocoa_refresh\n");
-graphic_hw_update(NULL);
-
-if (qemu_input_is_absolute()) {
-if (![cocoaView isAbsoluteEnabled]) {
-if ([cocoaView isMouseGrabbed]) {
-[cocoaView ungrabMouse];
-}
-}
-[cocoaView setAbsoluteEnabled:YES];
-}
-
-NSDate *distantPast;
-NSEvent *event;
-distantPast = [NSDate distantPast];
-do {
-event = [NSApp nextEventMatchingMask:NSEventMaskAny 
untilDate:distantPast
-inMode: NSDefaultRunLoopMode dequeue:YES];
-if (event != nil) {
-[cocoaView handleEvent:event];
-}
-} while(event != nil);
-[pool release];
+[[NSApp delegate] cocoa_refresh];
 }
 
 static void cocoa_cleanup(void)
-- 
2.14.3 (Apple Git-98)




[Qemu-devel] [PATCH v3] qemu-img.c: add help for each command

2018-09-25 Thread John Arbuckle
Add the ability for the user to display help for a certain command. 
Example: qemu-img create --help

What is printed is all the options available to this command and an example.

Signed-off-by: John Arbuckle 
---
v3 changes:
Fixed a bug that caused qemu-img to crash when running a command without
options.

v2 changes:
Removed block of string comparison code for each command.
Added a help_func field to the img_cmd_t struct.
Made strings longer than 80 characters wide.

 qemu-img.c | 660 +++--
 1 file changed, 559 insertions(+), 101 deletions(-)

diff --git a/qemu-img.c b/qemu-img.c
index 1acddf693c..e4d9baa550 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -52,6 +52,7 @@
 typedef struct img_cmd_t {
 const char *name;
 int (*handler)(int argc, char **argv);
+void (*help_func)(void);
 } img_cmd_t;
 
 enum {
@@ -76,11 +77,6 @@ typedef enum OutputFormat {
 /* Default to cache=writeback as data integrity is not important for qemu-img 
*/
 #define BDRV_DEFAULT_CACHE "writeback"
 
-static void format_print(void *opaque, const char *name)
-{
-printf(" %s", name);
-}
-
 static void QEMU_NORETURN GCC_FMT_ATTR(1, 2) error_exit(const char *fmt, ...)
 {
 va_list ap;
@@ -105,102 +101,546 @@ static void QEMU_NORETURN unrecognized_option(const 
char *option)
 error_exit("unrecognized option '%s'", option);
 }
 
-/* Please keep in synch with qemu-img.texi */
-static void QEMU_NORETURN help(void)
+/* Prints an overview of available help options */
+static void help(void)
 {
 const char *help_msg =
-   QEMU_IMG_VERSION
-   "usage: qemu-img [standard options] command [command options]\n"
-   "QEMU disk image utility\n"
-   "\n"
-   "'-h', '--help'   display this help and exit\n"
-   "'-V', '--version'output version information and exit\n"
-   "'-T', '--trace'  
[[enable=]][,events=][,file=]\n"
-   " specify tracing options\n"
-   "\n"
-   "Command syntax:\n"
-#define DEF(option, callback, arg_string)\
-   "  " arg_string "\n"
-#include "qemu-img-cmds.h"
-#undef DEF
-   "\n"
-   "Command parameters:\n"
-   "  'filename' is a disk image filename\n"
-   "  'objectdef' is a QEMU user creatable object definition. See the 
qemu(1)\n"
-   "manual page for a description of the object properties. The 
most common\n"
-   "object type is a 'secret', which is used to supply passwords 
and/or\n"
-   "encryption keys.\n"
-   "  'fmt' is the disk image format. It is guessed automatically in 
most cases\n"
-   "  'cache' is the cache mode used to write the output disk image, 
the valid\n"
-   "options are: 'none', 'writeback' (default, except for 
convert), 'writethrough',\n"
-   "'directsync' and 'unsafe' (default for convert)\n"
-   "  'src_cache' is the cache mode used to read input disk images, 
the valid\n"
-   "options are the same as for the 'cache' option\n"
-   "  'size' is the disk image size in bytes. Optional suffixes\n"
-   "'k' or 'K' (kilobyte, 1024), 'M' (megabyte, 1024k), 'G' 
(gigabyte, 1024M),\n"
-   "'T' (terabyte, 1024G), 'P' (petabyte, 1024T) and 'E' (exabyte, 
1024P)  are\n"
-   "supported. 'b' is ignored.\n"
-   "  'output_filename' is the destination disk image filename\n"
-   "  'output_fmt' is the destination format\n"
-   "  'options' is a comma separated list of format specific options 
in a\n"
-   "name=value format. Use -o ? for an overview of the options 
supported by the\n"
-   "used format\n"
-   "  'snapshot_param' is param used for internal snapshot, format\n"
-   "is 'snapshot.id=[ID],snapshot.name=[NAME]', or\n"
-   "'[ID_OR_NAME]'\n"
-   "  '-c' indicates that target image must be compressed (qcow format 
only)\n"
-   "  '-u' allows unsafe backing chains. For rebasing, it is assumed 
that old and\n"
-   "   new backing file match exactly. The image doesn't need a 
working\n"
-   "   backing file before rebasing in this case (useful for 
renaming the\n"
-   "   backing file). For image creation, allow creating without 
attempting\n"
-   "   to open the backing file.\n"
-   "  '-h' with or without a

Re: [Qemu-devel] [Bug 1332234] Re: qemu-system-ppc no longer able to read real cdrom

2018-09-24 Thread John Arbuckle
> On Sep 24, 2018, at 5:14 AM, Thomas Huth <1332...@bugs.launchpad.net> wrote:
> 
> According to https://bugs.launchpad.net/qemu/+bug/588691 CD-ROM drives
> should be working again, so I assume we can close this bug nowadays? Or
> can you still reproduce it with the latest version of QEMU?
> 
> ** Changed in: qemu
>   Status: New => Incomplete


I cannot reproduce this issue with QEMU. This report can now be closed. Thank 
you.


> 
> -- 
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1332234
> 
> Title:
>  qemu-system-ppc no longer able to read real cdrom
> 
> Status in QEMU:
>  Incomplete
> 
> Bug description:
>  When I use to send the -cdrom /dev/cdrom option to QEMU, I would be
>  able to use a real cdrom. With QEMU v2.0.0, real cdroms don't work. A
>  quick look at the output from the "info block" command shows this:
> 
>  ide1-cd0: /dev/cdrom (raw, read-only)
>Removable device: not locked, tray closed
> 
>  This indicates that the cdrom is set to /dev/cdrom. I remember
>  versions of QEMU prior to 1.5 were able to use a real cdrom.
> 
>  qemu-system-ppc is being run on Mac OS 10.6.8.
> 
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/qemu/+bug/1332234/+subscriptions

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1332234

Title:
  qemu-system-ppc no longer able to read real cdrom

Status in QEMU:
  Incomplete

Bug description:
  When I use to send the -cdrom /dev/cdrom option to QEMU, I would be
  able to use a real cdrom. With QEMU v2.0.0, real cdroms don't work. A
  quick look at the output from the "info block" command shows this:

  ide1-cd0: /dev/cdrom (raw, read-only)
Removable device: not locked, tray closed

  This indicates that the cdrom is set to /dev/cdrom. I remember
  versions of QEMU prior to 1.5 were able to use a real cdrom.

  qemu-system-ppc is being run on Mac OS 10.6.8.

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1332234/+subscriptions



[Qemu-devel] [PATCH] fix setting the FPSCR[FR] bit

2018-09-17 Thread John Arbuckle
https://www.nxp.com/files-static/product/doc/MPCFPE32B.pdf
Page 2-8 in table 2-4 is where the description of this bit can be found.

It is described as:

Floating-point fraction rounded. The last arithmetic, rounding, or conversion 
instruction incremented the fraction. This bit is NOT sticky.

This patch actually implements the setting and unsetting of this bit.

Signed-off-by: John Arbuckle 
---
 fpu/softfloat.c   | 12 ++--
 include/fpu/softfloat-types.h |  1 +
 target/ppc/fpu_helper.c   | 12 
 3 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/fpu/softfloat.c b/fpu/softfloat.c
index 59ca356d0e..c5378ae9e8 100644
--- a/fpu/softfloat.c
+++ b/fpu/softfloat.c
@@ -751,9 +751,17 @@ float64 __attribute__((flatten)) float64_add(float64 a, 
float64 b,
 {
 FloatParts pa = float64_unpack_canonical(a, status);
 FloatParts pb = float64_unpack_canonical(b, status);
-FloatParts pr = addsub_floats(pa, pb, false, status);
+FloatParts intermediate_parts = addsub_floats(pa, pb, false, status);
 
-return float64_round_pack_canonical(pr, status);
+float64 rounded_result = float64_round_pack_canonical(intermediate_parts,
+  status);
+FloatParts rounded_parts = float64_unpack_canonical(rounded_result, 
status);
+
+if (rounded_parts.frac != intermediate_parts.frac) {
+float_raise(float_flag_round, status);
+}
+
+return rounded_result;
 }
 
 float16 __attribute__((flatten)) float16_sub(float16 a, float16 b,
diff --git a/include/fpu/softfloat-types.h b/include/fpu/softfloat-types.h
index 2aae6a89b1..1d124e659c 100644
--- a/include/fpu/softfloat-types.h
+++ b/include/fpu/softfloat-types.h
@@ -147,6 +147,7 @@ enum {
 
 enum {
 float_flag_invalid   =  1,
+float_flag_round =  2,
 float_flag_divbyzero =  4,
 float_flag_overflow  =  8,
 float_flag_underflow = 16,
diff --git a/target/ppc/fpu_helper.c b/target/ppc/fpu_helper.c
index b9bb1b856e..eed4f1a650 100644
--- a/target/ppc/fpu_helper.c
+++ b/target/ppc/fpu_helper.c
@@ -581,6 +581,7 @@ static void do_float_check_status(CPUPPCState *env, 
uintptr_t raddr)
 CPUState *cs = CPU(ppc_env_get_cpu(env));
 int status = get_float_exception_flags(>fp_status);
 bool inexact_happened = false;
+bool round_happened = false;
 
 if (status & float_flag_overflow) {
 float_overflow_excp(env);
@@ -591,11 +592,22 @@ static void do_float_check_status(CPUPPCState *env, 
uintptr_t raddr)
 inexact_happened = true;
 }
 
+/* if the round flag was set */
+if (status & float_flag_round) {
+round_happened = true;
+env->fpscr |= 1 << FPSCR_FR;
+}
+
 /* if the inexact flag was not set */
 if (inexact_happened == false) {
 env->fpscr &= ~(1 << FPSCR_FI); /* clear the FPSCR[FI] bit */
 }
 
+/* if the floating-point fraction rounded bit was not set */
+if (round_happened == false) {
+env->fpscr &= ~(1 << FPSCR_FR); /* clear the FPSCR[FR] bit */
+}
+
 if (cs->exception_index == POWERPC_EXCP_PROGRAM &&
 (env->error_code & POWERPC_EXCP_FP)) {
 /* Differred floating-point exception after target FPR update */
-- 
2.14.3 (Apple Git-98)




[Qemu-devel] [PATCH v2] qemu-img.c: add help for each command

2018-09-15 Thread John Arbuckle
Add the ability for the user to display help for a certain command. 
Example: qemu-img create --help

What is printed is all the options available to this command and an example.

Signed-off-by: John Arbuckle 
---
v2 changes:
Removed block of string comparison code for each command.
Added a help_func field to the img_cmd_t struct.
Made strings longer than 80 characters wide.

 qemu-img.c | 659 +++--
 1 file changed, 558 insertions(+), 101 deletions(-)

diff --git a/qemu-img.c b/qemu-img.c
index 1acddf693c..7b9f6101b3 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -52,6 +52,7 @@
 typedef struct img_cmd_t {
 const char *name;
 int (*handler)(int argc, char **argv);
+void (*help_func)(void);
 } img_cmd_t;
 
 enum {
@@ -76,11 +77,6 @@ typedef enum OutputFormat {
 /* Default to cache=writeback as data integrity is not important for qemu-img 
*/
 #define BDRV_DEFAULT_CACHE "writeback"
 
-static void format_print(void *opaque, const char *name)
-{
-printf(" %s", name);
-}
-
 static void QEMU_NORETURN GCC_FMT_ATTR(1, 2) error_exit(const char *fmt, ...)
 {
 va_list ap;
@@ -105,102 +101,546 @@ static void QEMU_NORETURN unrecognized_option(const 
char *option)
 error_exit("unrecognized option '%s'", option);
 }
 
-/* Please keep in synch with qemu-img.texi */
-static void QEMU_NORETURN help(void)
+/* Prints an overview of available help options */
+static void help(void)
 {
 const char *help_msg =
-   QEMU_IMG_VERSION
-   "usage: qemu-img [standard options] command [command options]\n"
-   "QEMU disk image utility\n"
-   "\n"
-   "'-h', '--help'   display this help and exit\n"
-   "'-V', '--version'output version information and exit\n"
-   "'-T', '--trace'  
[[enable=]][,events=][,file=]\n"
-   " specify tracing options\n"
-   "\n"
-   "Command syntax:\n"
-#define DEF(option, callback, arg_string)\
-   "  " arg_string "\n"
-#include "qemu-img-cmds.h"
-#undef DEF
-   "\n"
-   "Command parameters:\n"
-   "  'filename' is a disk image filename\n"
-   "  'objectdef' is a QEMU user creatable object definition. See the 
qemu(1)\n"
-   "manual page for a description of the object properties. The 
most common\n"
-   "object type is a 'secret', which is used to supply passwords 
and/or\n"
-   "encryption keys.\n"
-   "  'fmt' is the disk image format. It is guessed automatically in 
most cases\n"
-   "  'cache' is the cache mode used to write the output disk image, 
the valid\n"
-   "options are: 'none', 'writeback' (default, except for 
convert), 'writethrough',\n"
-   "'directsync' and 'unsafe' (default for convert)\n"
-   "  'src_cache' is the cache mode used to read input disk images, 
the valid\n"
-   "options are the same as for the 'cache' option\n"
-   "  'size' is the disk image size in bytes. Optional suffixes\n"
-   "'k' or 'K' (kilobyte, 1024), 'M' (megabyte, 1024k), 'G' 
(gigabyte, 1024M),\n"
-   "'T' (terabyte, 1024G), 'P' (petabyte, 1024T) and 'E' (exabyte, 
1024P)  are\n"
-   "supported. 'b' is ignored.\n"
-   "  'output_filename' is the destination disk image filename\n"
-   "  'output_fmt' is the destination format\n"
-   "  'options' is a comma separated list of format specific options 
in a\n"
-   "name=value format. Use -o ? for an overview of the options 
supported by the\n"
-   "used format\n"
-   "  'snapshot_param' is param used for internal snapshot, format\n"
-   "is 'snapshot.id=[ID],snapshot.name=[NAME]', or\n"
-   "'[ID_OR_NAME]'\n"
-   "  '-c' indicates that target image must be compressed (qcow format 
only)\n"
-   "  '-u' allows unsafe backing chains. For rebasing, it is assumed 
that old and\n"
-   "   new backing file match exactly. The image doesn't need a 
working\n"
-   "   backing file before rebasing in this case (useful for 
renaming the\n"
-   "   backing file). For image creation, allow creating without 
attempting\n"
-   "   to open the backing file.\n"
-   "  '-h' with or without a command shows this help and lists the 
supported formats\n"
-   "  '-p' show progres

[Qemu-devel] [PATCH] qemu-common.h: update copyright date to 2018

2018-09-09 Thread John Arbuckle
Currently the copyright date is set to 2017. Update the date to say
2018.

Signed-off-by: John Arbuckle 
---
 include/qemu-common.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/qemu-common.h b/include/qemu-common.h
index 85f4749aef..ed60ba251d 100644
--- a/include/qemu-common.h
+++ b/include/qemu-common.h
@@ -17,7 +17,7 @@
 #define TFR(expr) do { if ((expr) != -1) break; } while (errno == EINTR)
 
 /* Copyright string for -version arguments, About dialogs, etc */
-#define QEMU_COPYRIGHT "Copyright (c) 2003-2017 " \
+#define QEMU_COPYRIGHT "Copyright (c) 2003-2018 " \
 "Fabrice Bellard and the QEMU Project developers"
 
 /* Bug reporting information for --help arguments, About dialogs, etc */
-- 
2.14.3 (Apple Git-98)




[Qemu-devel] [PATCH] qemu-img.c: add help for each command

2018-09-07 Thread John Arbuckle
Add the ability for the user to display help for a certain command. 
Example: qemu-img create --help

What is printed is all the options available to this command and an example.

Signed-off-by: John Arbuckle 
---
 qemu-img.c | 767 +
 1 file changed, 668 insertions(+), 99 deletions(-)

diff --git a/qemu-img.c b/qemu-img.c
index b12f4cd..5eb38b8 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -76,11 +76,6 @@ typedef enum OutputFormat {
 /* Default to cache=writeback as data integrity is not important for qemu-img 
*/
 #define BDRV_DEFAULT_CACHE "writeback"
 
-static void format_print(void *opaque, const char *name)
-{
-printf(" %s", name);
-}
-
 static void QEMU_NORETURN GCC_FMT_ATTR(1, 2) error_exit(const char *fmt, ...)
 {
 va_list ap;
@@ -105,102 +100,639 @@ static void QEMU_NORETURN unrecognized_option(const 
char *option)
 error_exit("unrecognized option '%s'", option);
 }
 
-/* Please keep in synch with qemu-img.texi */
-static void QEMU_NORETURN help(void)
+/* Prints an overview of available help options */
+static void help(void)
 {
 const char *help_msg =
-   QEMU_IMG_VERSION
-   "usage: qemu-img [standard options] command [command options]\n"
-   "QEMU disk image utility\n"
-   "\n"
-   "'-h', '--help'   display this help and exit\n"
-   "'-V', '--version'output version information and exit\n"
-   "'-T', '--trace'  
[[enable=]][,events=][,file=]\n"
-   " specify tracing options\n"
-   "\n"
-   "Command syntax:\n"
-#define DEF(option, callback, arg_string)\
-   "  " arg_string "\n"
-#include "qemu-img-cmds.h"
-#undef DEF
-   "\n"
-   "Command parameters:\n"
-   "  'filename' is a disk image filename\n"
-   "  'objectdef' is a QEMU user creatable object definition. See the 
qemu(1)\n"
-   "manual page for a description of the object properties. The 
most common\n"
-   "object type is a 'secret', which is used to supply passwords 
and/or\n"
-   "encryption keys.\n"
-   "  'fmt' is the disk image format. It is guessed automatically in 
most cases\n"
-   "  'cache' is the cache mode used to write the output disk image, 
the valid\n"
-   "options are: 'none', 'writeback' (default, except for 
convert), 'writethrough',\n"
-   "'directsync' and 'unsafe' (default for convert)\n"
-   "  'src_cache' is the cache mode used to read input disk images, 
the valid\n"
-   "options are the same as for the 'cache' option\n"
-   "  'size' is the disk image size in bytes. Optional suffixes\n"
-   "'k' or 'K' (kilobyte, 1024), 'M' (megabyte, 1024k), 'G' 
(gigabyte, 1024M),\n"
-   "'T' (terabyte, 1024G), 'P' (petabyte, 1024T) and 'E' (exabyte, 
1024P)  are\n"
-   "supported. 'b' is ignored.\n"
-   "  'output_filename' is the destination disk image filename\n"
-   "  'output_fmt' is the destination format\n"
-   "  'options' is a comma separated list of format specific options 
in a\n"
-   "name=value format. Use -o ? for an overview of the options 
supported by the\n"
-   "used format\n"
-   "  'snapshot_param' is param used for internal snapshot, format\n"
-   "is 'snapshot.id=[ID],snapshot.name=[NAME]', or\n"
-   "'[ID_OR_NAME]'\n"
-   "  '-c' indicates that target image must be compressed (qcow format 
only)\n"
-   "  '-u' allows unsafe backing chains. For rebasing, it is assumed 
that old and\n"
-   "   new backing file match exactly. The image doesn't need a 
working\n"
-   "   backing file before rebasing in this case (useful for 
renaming the\n"
-   "   backing file). For image creation, allow creating without 
attempting\n"
-   "   to open the backing file.\n"
-   "  '-h' with or without a command shows this help and lists the 
supported formats\n"
-   "  '-p' show progress of command (only certain commands)\n"
-   "  '-q' use Quiet mode - do not print any output (except errors)\n"
-   "  '-S' indicates the consecutive number of bytes (defaults to 4k) 
that must\n"
-   "   contain only zeros for qemu-img to create a sparse image 
during\n"

[Qemu-devel] [Bug 588691] Re: QEMU is not correctly detecting host CDs

2018-09-03 Thread John Arbuckle
I use real CD-ROM disc in Mac OS and Windows guests on my Mac OS 10.12
host. I have to run QEMU in root mode using the sudo command in order to
access the CD-ROM drive. So I know QEMU's support for using real optical
media on Mac OS hosts does work.

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/588691

Title:
  QEMU is not correctly detecting host CDs

Status in QEMU:
  Incomplete

Bug description:
  QEMU's block layer contains code for detecting and using ioctls when
  real CD-ROM host devices are attached.

  This detection is not working in some host OSes while bad implemented
  on anothers.

  E.g., in Linux host qemu -cdrom /dev/sr0 is not detecting it as a CD-ROM
  E.g., in Mac OS X host qemu asks the kernel to enumerate optical devices and 
the compares it to the constant string "/dev/cdrom". This is useless, that 
enumeration is just enough, and "/dev/cdrom" will NEVER exist in Mac OS X 
unless manually created by the user.

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/588691/+subscriptions



[Qemu-devel] [PATCH] hw/input/ps2.c: fix erratic mouse behavior for Windows 3.1

2018-08-18 Thread John Arbuckle
When the user moves the mouse and moves the scroll wheel at the same time, the 
mouse cursor's movement becomes erratic in Windows 3.1. With this patch if the 
mouse is in ps/2 mode and the scroll wheel is used, the command queue is reset. 
This does not fix the erratic mouse problem in Windows NT 4.0.

Signed-off-by: John Arbuckle 
---
 hw/input/ps2.c | 11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/hw/input/ps2.c b/hw/input/ps2.c
index fdfcadf9a1..bb9ebfa5a9 100644
--- a/hw/input/ps2.c
+++ b/hw/input/ps2.c
@@ -685,8 +685,17 @@ static int ps2_mouse_send_packet(PS2MouseState *s)
 /* update deltas */
 s->mouse_dx -= dx1;
 s->mouse_dy -= dy1;
-s->mouse_dz -= dz1;
+/*
+ * This prevents the mouse from going crazy in Windows that doesn't support
+ * the Microsoft Intellimouse standard.
+ */
+if (s->mouse_type == 0 && s->mouse_dz != 0) {
+s->mouse_dz = 0;
+ps2_reset_queue(>common);
+return 1;
+}
 
+s->mouse_dz -= dz1;
 return 1;
 }
 
-- 
2.14.3 (Apple Git-98)




[Qemu-devel] [Bug 1785485] [NEW] Mouse moves erratically when using scroll wheel on Windows NT 4, Windows 95, and Windows 3.1 guests

2018-08-05 Thread John Arbuckle
Public bug reported:

QEMU version: 3.0.0 RC3
Guests: Windows NT 4.0, Windows 95, Windows 3.1

Program: When the user uses the scroll wheel, the mouse's movement
becomes erratic.

This is noticed immediately when the scroll wheel is used. Sometimes the
problem can be fixed by moving the scroll wheel some more.

My theory is this problem is because of the lack of support for the
Microsoft Intellimouse in these guest operating systems.

** Affects: qemu
 Importance: Undecided
 Status: New


** Tags: qemu-system-i386

** Tags added: qemu-system-i386

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1785485

Title:
  Mouse moves erratically when using scroll wheel on Windows NT 4,
  Windows 95, and Windows 3.1 guests

Status in QEMU:
  New

Bug description:
  QEMU version: 3.0.0 RC3
  Guests: Windows NT 4.0, Windows 95, Windows 3.1

  Program: When the user uses the scroll wheel, the mouse's movement
  becomes erratic.

  This is noticed immediately when the scroll wheel is used. Sometimes
  the problem can be fixed by moving the scroll wheel some more.

  My theory is this problem is because of the lack of support for the
  Microsoft Intellimouse in these guest operating systems.

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1785485/+subscriptions



[Qemu-devel] [PATCH] qemu-img.c: Add examples section

2018-08-02 Thread John Arbuckle
Add an examples section to the help output.

Signed-off-by: John Arbuckle 
---
 qemu-img.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/qemu-img.c b/qemu-img.c
index 1acddf693c..f77c82695d 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -199,6 +199,17 @@ static void QEMU_NORETURN help(void)
 
 printf("%s\nSupported formats:", help_msg);
 bdrv_iterate_format(format_print, NULL);
+
+printf("\n\nExamples:\n\n"
+   "Create: qemu-img create -f qcow2 image.qcow2 10G\n\n"
+   "Info: qemu-img info image.qcow2\n\n"
+   "Resize: qemu-img resize image.qcow2 20G\n\n"
+   "Convert: qemu-img convert -f raw -O qcow2 image.img 
image.qcow2\n\n"
+   "Check: qemu-img check image.qcow2\n\n"
+   "Map: qemu-img map -f qcow2 --output=human image.qcow2\n\n"
+   "Rebase: qemu-img rebase -b new_backing_file.qcow2 image.qcow2"
+   );
+
 printf("\n\n" QEMU_HELP_BOTTOM "\n");
 exit(EXIT_SUCCESS);
 }
-- 
2.14.3 (Apple Git-98)




[Qemu-devel] [PATCH] qemu-img-cmds.hx: Add example usage for create command

2018-07-30 Thread John Arbuckle
Add an example on how to use the create command. I believe this will make 
qemu-img easier to use.

Signed-off-by: John Arbuckle 
---
 qemu-img-cmds.hx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qemu-img-cmds.hx b/qemu-img-cmds.hx
index 69758fb6e8..92f7437944 100644
--- a/qemu-img-cmds.hx
+++ b/qemu-img-cmds.hx
@@ -50,7 +50,7 @@ STEXI
 ETEXI
 
 DEF("create", img_create,
-"create [--object objectdef] [-q] [-f fmt] [-b backing_file] [-F 
backing_fmt] [-u] [-o options] filename [size]")
+"create [--object objectdef] [-q] [-f fmt] [-b backing_file] [-F 
backing_fmt] [-u] [-o options] filename [size]\nExample: qemu-img create -f 
qcow2 WindowsXP.qcow2 10G")
 STEXI
 @item create [--object @var{objectdef}] [-q] [-f @var{fmt}] [-b 
@var{backing_file}] [-F @var{backing_fmt}] [-u] [-o @var{options}] 
@var{filename} [@var{size}]
 ETEXI
-- 
2.14.3 (Apple Git-98)




[Qemu-devel] [PATCH] Add interactive mode to qemu-img command

2018-07-30 Thread John Arbuckle
Changes qemu-img so if the user runs it without any
arguments, it will walk the user thru making an image
file.

Signed-off-by: John Arbuckle 
---
 qemu-img.c | 31 +--
 1 file changed, 29 insertions(+), 2 deletions(-)

diff --git a/qemu-img.c b/qemu-img.c
index 9b7506b8ae..aa3df3b431 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -4873,6 +4873,32 @@ out:
 return ret;
 }
 
+/* Guides the user on making an image file */
+static int interactive_mode()
+{
+char format[100];
+char size[100];
+char name[1000];
+
+printf("\nInteractive mode (Enter Control-C to cancel)\n");
+printf("Please select a format (qcow, qcow2, raw, vdi, vhdx, vmdk, vpc): 
");
+scanf("%100s", format);
+printf("Please enter a size (e.g. 100M, 10G): ");
+scanf("%100s", size);
+printf("Please enter a name: ");
+scanf("%1000s", name);
+
+const char *arguments[] = {"create", "-f", format, name, size};
+int arg_count = 5;
+int return_value;
+return_value = img_create(arg_count, (char **)arguments);
+if (return_value == 0) {
+printf("Done creating image file\n");
+}
+
+return return_value;
+}
+
 static const img_cmd_t img_cmds[] = {
 #define DEF(option, callback, arg_string)\
 { option, callback },
@@ -4912,8 +4938,9 @@ int main(int argc, char **argv)
 
 module_call_init(MODULE_INIT_QOM);
 bdrv_init();
-if (argc < 2) {
-error_exit("Not enough arguments");
+
+if (argc == 1) { /* If no arguments passed to qemu-img */
+return interactive_mode();
 }
 
 qemu_add_opts(_object_opts);
-- 
2.14.3 (Apple Git-98)




[Qemu-devel] [PATCH v3] ui/cocoa.m: replace scrollingDeltaY with deltaY

2018-07-09 Thread John Arbuckle
The NSEvent class method scrollingDeltaY is available
for Mac OS 10.7 and newer. Since QEMU supports Mac OS
10.5 and up, we need to be using a method that is
available on these version of Mac OS X. The deltaY
method is a method that does the same thing as
scrollingDeltaY and is available on Mac OS 10.5 and
up. So we replace scrollingDeltaY with deltaY. 

We only check deltaY's value if it is not zero
because zero means no scrolling took place.

Signed-off-by: John Arbuckle 
---
v3 changes:
- Added a comment explaining why we drop scrolling events in both the code and
the patch comment.

v2 changes:
- Added a condition that drops scroll events that have a deltaY value of zero.

 ui/cocoa.m | 19 ---
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/ui/cocoa.m b/ui/cocoa.m
index 2991ed4f19..3bae090101 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -802,14 +802,19 @@ - (void) handleEvent:(NSEvent *)event
  * This is in-line with standard Mac OS X UI behaviour.
  */
 
+/*
+ * When deltaY is zero, it means the scrolling device did not move
+ * for this event. So we drop the event.
+ */
+if ([event deltaY] != 0) {
 /* Determine if this is a scroll up or scroll down event */
-buttons = ([event scrollingDeltaY] > 0) ?
-INPUT_BUTTON_WHEEL_UP : INPUT_BUTTON_WHEEL_DOWN;
-qemu_input_queue_btn(dcl->con, buttons, true);
-qemu_input_event_sync();
-qemu_input_queue_btn(dcl->con, buttons, false);
-qemu_input_event_sync();
-
+buttons = ([event deltaY] > 0) ?
+INPUT_BUTTON_WHEEL_UP : INPUT_BUTTON_WHEEL_DOWN;
+qemu_input_queue_btn(dcl->con, buttons, true);
+qemu_input_event_sync();
+qemu_input_queue_btn(dcl->con, buttons, false);
+qemu_input_event_sync();
+}
 /*
  * Since deltaY also reports scroll wheel events we prevent mouse
  * movement code from executing.
-- 
2.14.3 (Apple Git-98)




[Qemu-devel] [PATCH v2] ui/cocoa.m: replace scrollingDeltaY with deltaY

2018-07-05 Thread John Arbuckle
The NSEvent class method scrollingDeltaY is available
for Mac OS 10.7 and newer. Since QEMU supports Mac OS
10.5 and up, we need to be using a method that is
available on these version of Mac OS X. The deltaY
method is a method that does the same thing as
scrollingDeltaY and is available on Mac OS 10.5 and
up. So we simply replace scrollingDeltaY with deltaY.

Signed-off-by: John Arbuckle 
---
v2 changes:
- Added a condition that drops scroll events that have a deltaY value of zero.

 ui/cocoa.m | 15 ---
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/ui/cocoa.m b/ui/cocoa.m
index 2991ed4..f371469 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -802,14 +802,15 @@ QemuCocoaView *cocoaView;
  * This is in-line with standard Mac OS X UI behaviour.
  */
 
+if ([event deltaY] != 0) {
 /* Determine if this is a scroll up or scroll down event */
-buttons = ([event scrollingDeltaY] > 0) ?
-INPUT_BUTTON_WHEEL_UP : INPUT_BUTTON_WHEEL_DOWN;
-qemu_input_queue_btn(dcl->con, buttons, true);
-qemu_input_event_sync();
-qemu_input_queue_btn(dcl->con, buttons, false);
-qemu_input_event_sync();
-
+buttons = ([event deltaY] > 0) ?
+INPUT_BUTTON_WHEEL_UP : INPUT_BUTTON_WHEEL_DOWN;
+qemu_input_queue_btn(dcl->con, buttons, true);
+qemu_input_event_sync();
+qemu_input_queue_btn(dcl->con, buttons, false);
+qemu_input_event_sync();
+}
 /*
  * Since deltaY also reports scroll wheel events we prevent mouse
  * movement code from executing.
-- 
2.7.2




[Qemu-devel] [RFC] fix setting FPSCR[FR] bit

2018-07-05 Thread John Arbuckle
https://www.pdfdrive.net/powerpc-microprocessor-family-the-programming-environments-for-32-e3087633.html
Page 63 in table 2-4 is where the description of this bit can be found.

It is described as:

Floating-point fraction rounded. The last arithmetic or rounding and conversion 
instruction that rounded the intermediate result incremented the fraction. This 
bit is NOT sticky.

What I think this means is when the softfloat.c:round_canonical() function adds 
the inc variable to the frac variable, the floating point fraction rounded bit 
should be set. It also means that every time a floating point operation takes 
place, this bit needs to be updated since it isn't a sticky bit. My testing has 
produced mixed results with this patch. Some of my floating point tests are 
fixed by this patch, and others are broken by this patch. I'm not clear if this 
is the right way to implement setting the FPSCR[FR] bit. Feedback would be 
great.

Signed-off-by: John Arbuckle 
---
 fpu/softfloat.c   | 6 +-
 include/fpu/softfloat-types.h | 1 +
 target/ppc/fpu_helper.c   | 8 
 3 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/fpu/softfloat.c b/fpu/softfloat.c
index 8cd2400081..b2b2c61cff 100644
--- a/fpu/softfloat.c
+++ b/fpu/softfloat.c
@@ -382,11 +382,12 @@ static FloatParts round_canonical(FloatParts p, 
float_status *s,
 const uint64_t roundeven_mask = parm->roundeven_mask;
 const int exp_max = parm->exp_max;
 const int frac_shift = parm->frac_shift;
-uint64_t frac, inc;
+uint64_t frac, inc, old_frac;
 int exp, flags = 0;
 bool overflow_norm;
 
 frac = p.frac;
+old_frac = frac; /* Used to determine if the fraction was rounded */
 exp = p.exp;
 
 switch (p.cls) {
@@ -503,6 +504,9 @@ static FloatParts round_canonical(FloatParts p, 
float_status *s,
 g_assert_not_reached();
 }
 
+if (frac != old_frac) {
+flags |= float_flag_round;
+}
 float_raise(flags, s);
 p.exp = exp;
 p.frac = frac;
diff --git a/include/fpu/softfloat-types.h b/include/fpu/softfloat-types.h
index 2aae6a89b1..1d124e659c 100644
--- a/include/fpu/softfloat-types.h
+++ b/include/fpu/softfloat-types.h
@@ -147,6 +147,7 @@ enum {
 
 enum {
 float_flag_invalid   =  1,
+float_flag_round =  2,
 float_flag_divbyzero =  4,
 float_flag_overflow  =  8,
 float_flag_underflow = 16,
diff --git a/target/ppc/fpu_helper.c b/target/ppc/fpu_helper.c
index cb82e6e842..ba57ea7cfe 100644
--- a/target/ppc/fpu_helper.c
+++ b/target/ppc/fpu_helper.c
@@ -581,6 +581,7 @@ static void do_float_check_status(CPUPPCState *env, 
uintptr_t raddr)
 CPUState *cs = CPU(ppc_env_get_cpu(env));
 int status = get_float_exception_flags(>fp_status);
 bool inexact_happened = false;
+bool round_happened = false;
 
 if (status & float_flag_overflow) {
 float_overflow_excp(env);
@@ -589,6 +590,8 @@ static void do_float_check_status(CPUPPCState *env, 
uintptr_t raddr)
 } else if (status & float_flag_inexact) {
 float_inexact_excp(env);
 inexact_happened = true;
+} else if (status & float_flag_round) {
+round_happened = true;
 }
 
 /* if the inexact flag was not set */
@@ -596,6 +599,11 @@ static void do_float_check_status(CPUPPCState *env, 
uintptr_t raddr)
 env->fpscr &= ~(1 << FPSCR_FI); /* clear the FPSCR[FI] bit */
 }
 
+/* if the floating-point fraction rounded bit was not set */
+if (round_happened == false) {
+env->fpscr &= ~(1 << FPSCR_FR); /* clear the FPSCR[FR] bit */
+}
+
 if (cs->exception_index == POWERPC_EXCP_PROGRAM &&
 (env->error_code & POWERPC_EXCP_FP)) {
 /* Differred floating-point exception after target FPR update */
-- 
2.14.3 (Apple Git-98)




[Qemu-devel] [PATCH] ui/cocoa.m: replace scrollingDeltaY with deltaY

2018-07-02 Thread John Arbuckle
The NSEvent class method scrollingDeltaY is available for Mac OS 10.7 and 
newer. Since QEMU supports Mac OS 10.5 and up, we need to be using a method 
that is available on these version of Mac OS X. The deltaY method is a method 
that does the same thing as scrollingDeltaY and is available on Mac OS 10.5 and 
up. So we simply replace scrollingDeltaY with deltaY.

Signed-off-by: John Arbuckle 
---
 ui/cocoa.m | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ui/cocoa.m b/ui/cocoa.m
index 2991ed4f19..e34714081d 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -803,7 +803,7 @@ - (void) handleEvent:(NSEvent *)event
  */
 
 /* Determine if this is a scroll up or scroll down event */
-buttons = ([event scrollingDeltaY] > 0) ?
+buttons = ([event deltaY] > 0) ?
 INPUT_BUTTON_WHEEL_UP : INPUT_BUTTON_WHEEL_DOWN;
 qemu_input_queue_btn(dcl->con, buttons, true);
 qemu_input_event_sync();
-- 
2.14.3 (Apple Git-98)




[Qemu-devel] [PATCH v2] ui/cocoa.m: prevent stuck command key when going into full screen mode

2018-07-02 Thread John Arbuckle
When the user pushes Command-F in QEMU while the mouse is ungrabbed, QEMU
goes into full screen mode. When the user finally releases the command key,
it is sent to the guest as an event. The makes the guest operating system
think the command key is down when it is really up. To prevent this situation
from happening, we simply drop the first command key event after the user has
gone into full screen mode using Command-F.

Signed-off-by: John Arbuckle 
---
v2 changes:
Code changes now confined to the handleEvent: method.

 ui/cocoa.m | 14 +-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/ui/cocoa.m b/ui/cocoa.m
index 2991ed4..9be4811 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -637,6 +637,7 @@ QemuCocoaView *cocoaView;
 int buttons = 0;
 int keycode = 0;
 bool mouse_event = false;
+static bool switched_to_fullscreen = false;
 NSPoint p = [event locationInWindow];
 
 switch ([event type]) {
@@ -681,7 +682,11 @@ QemuCocoaView *cocoaView;
 keycode == Q_KEY_CODE_NUM_LOCK) {
 [self toggleStatefulModifier:keycode];
 } else if (qemu_console_is_graphic(NULL)) {
-  [self toggleModifier:keycode];
+if (switched_to_fullscreen) {
+switched_to_fullscreen = false;
+} else {
+[self toggleModifier:keycode];
+}
 }
 }
 
@@ -691,6 +696,13 @@ QemuCocoaView *cocoaView;
 
 // forward command key combos to the host UI unless the mouse is 
grabbed
 if (!isMouseGrabbed && ([event modifierFlags] & 
NSEventModifierFlagCommand)) {
+/*
+ * Prevent the command key from being stuck down in the guest
+ * when using Command-F to switch to full screen mode.
+ */
+if (keycode == Q_KEY_CODE_F) {
+switched_to_fullscreen = true;
+}
 [NSApp sendEvent:event];
 return;
 }
-- 
2.7.2




[Qemu-devel] [PATCH v2] fix fdiv instruction

2018-06-29 Thread John Arbuckle
When the fdiv instruction divides a finite number by zero,
the result actually depends on the FPSCR[ZE] bit. If this
bit is set, the return value is the value originally in
the destination register. If it is not set
the result should be either positive or negative infinity.
The sign of this result would depend on the sign of the
two inputs. What currently happens is only infinity is
returned even if the FPSCR[ZE] bit is set. This patch
fixes this problem by actually checking the FPSCR[ZE] bit
when deciding what the answer should be.

fdiv is suppose to only set the FPSCR's FPRF bits during a
division by zero situation when the FPSCR[ZE] is not set.
What currently happens is these bits are always set. This
patch fixes this problem by checking the FPSCR[ZE] bit to
decide if the FPRF bits should be set. 

https://www.pdfdrive.net/powerpc-microprocessor-family-the-programming-environments-for-32-e3087633.html
This document has the information on the fdiv. Page 133 has
the information on what action is executed when a division
by zero situation takes place.

Signed-off-by: John Arbuckle 
---
v2 changes:
- Added comment for computing sign bit.
- Changed return value of helper_fdiv() to return the
  original value in the destination register when the
  fpscr_ze if condition is encountered.
- Patch comment adjusted to reflect returning
  destination register's value instead of zero.

 target/ppc/fpu_helper.c| 21 -
 target/ppc/helper.h|  2 +-
 target/ppc/translate/fp-impl.inc.c | 29 -
 3 files changed, 49 insertions(+), 3 deletions(-)

diff --git a/target/ppc/fpu_helper.c b/target/ppc/fpu_helper.c
index 7714bfe0f9..9ccba1ec3f 100644
--- a/target/ppc/fpu_helper.c
+++ b/target/ppc/fpu_helper.c
@@ -644,7 +644,8 @@ uint64_t helper_fmul(CPUPPCState *env, uint64_t arg1, 
uint64_t arg2)
 }
 
 /* fdiv - fdiv. */
-uint64_t helper_fdiv(CPUPPCState *env, uint64_t arg1, uint64_t arg2)
+uint64_t helper_fdiv(CPUPPCState *env, uint64_t arg1, uint64_t arg2, uint64_t
+ old_value)
 {
 CPU_DoubleU farg1, farg2;
 
@@ -658,6 +659,22 @@ uint64_t helper_fdiv(CPUPPCState *env, uint64_t arg1, 
uint64_t arg2)
 } else if (unlikely(float64_is_zero(farg1.d) && float64_is_zero(farg2.d))) 
{
 /* Division of zero by zero */
 farg1.ll = float_invalid_op_excp(env, POWERPC_EXCP_FP_VXZDZ, 1);
+} else if (arg2 == 0) {
+/* Division by zero */
+float_zero_divide_excp(env, GETPC());
+if (fpscr_ze) { /* if zero divide exception is enabled */
+/* Keep the value in the destination register the same */
+farg1.ll = old_value;
+} else {
+/* Compute sign bit */
+uint64_t sign = (farg1.ll ^ farg2.ll) >> 63;
+if (sign) { /* Negative sign bit */
+farg1.ll = 0xfff0; /* Negative Infinity */
+} else { /* Positive sign bit */
+farg1.ll = 0x7ff0; /* Positive Infinity */
+}
+helper_compute_fprf_float64(env, farg1.d);
+}
 } else {
 if (unlikely(float64_is_signaling_nan(farg1.d, >fp_status) ||
  float64_is_signaling_nan(farg2.d, >fp_status))) {
@@ -665,6 +682,8 @@ uint64_t helper_fdiv(CPUPPCState *env, uint64_t arg1, 
uint64_t arg2)
 float_invalid_op_excp(env, POWERPC_EXCP_FP_VXSNAN, 1);
 }
 farg1.d = float64_div(farg1.d, farg2.d, >fp_status);
+helper_compute_fprf_float64(env, farg1.d);
+helper_float_check_status(env);
 }
 
 return farg1.ll;
diff --git a/target/ppc/helper.h b/target/ppc/helper.h
index d751f0e219..ced3e99d71 100644
--- a/target/ppc/helper.h
+++ b/target/ppc/helper.h
@@ -88,7 +88,7 @@ DEF_HELPER_2(frim, i64, env, i64)
 DEF_HELPER_3(fadd, i64, env, i64, i64)
 DEF_HELPER_3(fsub, i64, env, i64, i64)
 DEF_HELPER_3(fmul, i64, env, i64, i64)
-DEF_HELPER_3(fdiv, i64, env, i64, i64)
+DEF_HELPER_4(fdiv, i64, env, i64, i64, i64)
 DEF_HELPER_4(fmadd, i64, env, i64, i64, i64)
 DEF_HELPER_4(fmsub, i64, env, i64, i64, i64)
 DEF_HELPER_4(fnmadd, i64, env, i64, i64, i64)
diff --git a/target/ppc/translate/fp-impl.inc.c 
b/target/ppc/translate/fp-impl.inc.c
index 2fbd4d4f38..fa29616b87 100644
--- a/target/ppc/translate/fp-impl.inc.c
+++ b/target/ppc/translate/fp-impl.inc.c
@@ -84,6 +84,33 @@ static void gen_f##name(DisasContext *ctx)   
 \
 _GEN_FLOAT_AB(name, name, 0x3F, op2, inval, 0, set_fprf, type);   \
 _GEN_FLOAT_AB(name##s, name, 0x3B, op2, inval, 1, set_fprf, type);
 
+
+#define _GEN_FLOAT_DIV(name, op, op1, op2, inval, isfloat, set_fprf, type)\
+static void gen_f##name(DisasContext *ctx)\
+{ \
+if (unlikely(!ctx->fpu_enabled)) {\

[Qemu-devel] [PATCH] fpu_helper.c: fix setting FPSCR[FI] bit

2018-06-24 Thread John Arbuckle
The FPSCR[FI] bit indicates if the last floating point instruction had a result 
that was rounded. Each consecutive floating point instruction is suppose to set 
this bit to the correct value. What currently happens is this bit is not set as 
often as it should be. I have verified that this is the behavior of a real 
PowerPC 950. This patch fixes that problem by deciding to set this bit after 
each floating point instruction.

https://www.pdfdrive.net/powerpc-microprocessor-family-the-programming-environments-for-32-e3087633.html
Page 63 in table 2-4 is where the description of this bit can be found.

Signed-off-by: John Arbuckle 
---
 target/ppc/fpu_helper.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/target/ppc/fpu_helper.c b/target/ppc/fpu_helper.c
index d31a933cbb..9c841864c8 100644
--- a/target/ppc/fpu_helper.c
+++ b/target/ppc/fpu_helper.c
@@ -274,6 +274,7 @@ static inline void float_inexact_excp(CPUPPCState *env)
 {
 CPUState *cs = CPU(ppc_env_get_cpu(env));
 
+env->fpscr |= 1 << FPSCR_FI;
 env->fpscr |= 1 << FPSCR_XX;
 /* Update the floating-point exception summary */
 env->fpscr |= FP_FX;
@@ -505,6 +506,7 @@ static void do_float_check_status(CPUPPCState *env, 
uintptr_t raddr)
 {
 CPUState *cs = CPU(ppc_env_get_cpu(env));
 int status = get_float_exception_flags(>fp_status);
+bool inexact_happened = false;
 
 if (status & float_flag_divbyzero) {
 float_zero_divide_excp(env, raddr);
@@ -514,6 +516,12 @@ static void do_float_check_status(CPUPPCState *env, 
uintptr_t raddr)
 float_underflow_excp(env);
 } else if (status & float_flag_inexact) {
 float_inexact_excp(env);
+inexact_happened = true;
+}
+
+/* if the inexact flag was not set */
+if (inexact_happened == false) {
+env->fpscr &= ~(1 << FPSCR_FI); /* clear the FPSCR[FI] bit */
 }
 
 if (cs->exception_index == POWERPC_EXCP_PROGRAM &&
-- 
2.14.3 (Apple Git-98)




[Qemu-devel] [PATCH] fix fdiv instruction

2018-06-22 Thread John Arbuckle
When the fdiv instruction divides a finite number by zero,
the result actually depends on the FPSCR[ZE] bit. If this
bit is set, the return value is zero. If it is not set
the result should be either positive or negative infinity.
The sign of this result would depend on the sign of the
two inputs. What currently happens is only infinity is
returned even if the FPSCR[ZE] bit is set. This patch
fixes this problem by actually checking the FPSCR[ZE] bit
when deciding what the answer should be.

fdiv is suppose to only set the FPSCR's FPRF bits during a
division by zero situation when the FPSCR[ZE] is not set.
What currently happens is these bits are always set. This
patch fixes this problem by checking the FPSCR[ZE] bit to
decide if the FPRF bits should be set. 

https://www.pdfdrive.net/powerpc-microprocessor-family-the-programming-environments-for-32-e3087633.html
This document has the information on the fdiv. Page 133 has the information on 
what action is executed when a division by zero situation takes place. 

Signed-off-by: John Arbuckle 
---
 target/ppc/fpu_helper.c| 16 
 target/ppc/translate/fp-impl.inc.c | 28 +++-
 2 files changed, 43 insertions(+), 1 deletion(-)

diff --git a/target/ppc/fpu_helper.c b/target/ppc/fpu_helper.c
index 7714bfe0f9..de694604fb 100644
--- a/target/ppc/fpu_helper.c
+++ b/target/ppc/fpu_helper.c
@@ -658,6 +658,20 @@ uint64_t helper_fdiv(CPUPPCState *env, uint64_t arg1, 
uint64_t arg2)
 } else if (unlikely(float64_is_zero(farg1.d) && float64_is_zero(farg2.d))) 
{
 /* Division of zero by zero */
 farg1.ll = float_invalid_op_excp(env, POWERPC_EXCP_FP_VXZDZ, 1);
+} else if (arg2 == 0) {
+/* Division by zero */
+float_zero_divide_excp(env, GETPC());
+if (fpscr_ze) { /* if zero divide exception is enabled */
+farg1.ll = 0;
+} else {
+uint64_t sign = (farg1.ll ^ farg2.ll) >> 63;
+if (sign) { /* Negative sign bit */
+farg1.ll = 0xfff0; /* Negative Infinity */
+} else { /* Positive sign bit */
+farg1.ll = 0x7ff0; /* Positive Infinity */
+}
+helper_compute_fprf_float64(env, farg1.d);
+}
 } else {
 if (unlikely(float64_is_signaling_nan(farg1.d, >fp_status) ||
  float64_is_signaling_nan(farg2.d, >fp_status))) {
@@ -665,6 +679,8 @@ uint64_t helper_fdiv(CPUPPCState *env, uint64_t arg1, 
uint64_t arg2)
 float_invalid_op_excp(env, POWERPC_EXCP_FP_VXSNAN, 1);
 }
 farg1.d = float64_div(farg1.d, farg2.d, >fp_status);
+helper_compute_fprf_float64(env, farg1.d);
+helper_float_check_status(env);
 }
 
 return farg1.ll;
diff --git a/target/ppc/translate/fp-impl.inc.c 
b/target/ppc/translate/fp-impl.inc.c
index 2fbd4d4f38..4e20bcceb4 100644
--- a/target/ppc/translate/fp-impl.inc.c
+++ b/target/ppc/translate/fp-impl.inc.c
@@ -84,6 +84,32 @@ static void gen_f##name(DisasContext *ctx)   
 \
 _GEN_FLOAT_AB(name, name, 0x3F, op2, inval, 0, set_fprf, type);   \
 _GEN_FLOAT_AB(name##s, name, 0x3B, op2, inval, 1, set_fprf, type);
 
+
+#define _GEN_FLOAT_DIV(name, op, op1, op2, inval, isfloat, set_fprf, type)\
+static void gen_f##name(DisasContext *ctx)\
+{ \
+if (unlikely(!ctx->fpu_enabled)) {\
+gen_exception(ctx, POWERPC_EXCP_FPU); \
+return;   \
+} \
+gen_reset_fpstatus(); \
+gen_helper_f##op(cpu_fpr[rD(ctx->opcode)], cpu_env,   \
+ cpu_fpr[rA(ctx->opcode)],\
+ cpu_fpr[rB(ctx->opcode)]);   \
+if (isfloat) {\
+gen_helper_frsp(cpu_fpr[rD(ctx->opcode)], cpu_env,\
+cpu_fpr[rD(ctx->opcode)]);\
+} \
+if (unlikely(Rc(ctx->opcode) != 0)) { \
+gen_set_cr1_from_fpscr(ctx);  \
+} \
+}
+
+#define GEN_FLOAT_DIV(name, op2, inval, set_fprf, type)   \
+_GEN_FLOAT_DIV(name, name, 0x3F, op2, inval, 0, set_fprf, type);  \
+_GEN_FLOAT_DIV(name##s, name, 0x3B, op2, inval, 1, set_fprf, type);
+

[Qemu-devel] [PATCH] ui/cocoa.m: prevent stuck command key when going into full screen mode

2018-06-18 Thread John Arbuckle
When the user pushes Command-F in QEMU while the mouse is ungrabbed, QEMU
goes into full screen mode. When the user finally releases the command key,
it is sent to the guest as an event. The makes the guest operating system
think the command key is down when it is really up. To prevent this situation
from happening, we simply drop the first command key event after the user has
gone into full screen mode using Command-F.

Signed-off-by: John Arbuckle 
---
 ui/cocoa.m | 18 +-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/ui/cocoa.m b/ui/cocoa.m
index 2991ed4..024aba2 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -287,6 +287,7 @@ static void handleAnyDeviceErrors(Error * err)
 BOOL isFullscreen;
 BOOL isAbsoluteEnabled;
 BOOL isMouseDeassociated;
+BOOL prevent_stuck_command_key;
 }
 - (void) switchSurface:(DisplaySurface *)surface;
 - (void) grabMouse;
@@ -330,7 +331,7 @@ QemuCocoaView *cocoaView;
 screen.bitsPerPixel = 32;
 screen.width = frameRect.size.width;
 screen.height = frameRect.size.height;
-
+prevent_stuck_command_key = NO;
 }
 return self;
 }
@@ -552,6 +553,14 @@ QemuCocoaView *cocoaView;
 }
 
 - (void) toggleModifier: (int)keycode {
+
+/* Prevents the command key from being sent to the guest */
+if ((keycode == Q_KEY_CODE_META_L || keycode == Q_KEY_CODE_META_R) &&
+prevent_stuck_command_key == YES) {
+prevent_stuck_command_key = NO;
+return;
+}
+
 // Toggle the stored state.
 modifiers_state[keycode] = !modifiers_state[keycode];
 // Send a keyup or keydown depending on the state.
@@ -691,6 +700,13 @@ QemuCocoaView *cocoaView;
 
 // forward command key combos to the host UI unless the mouse is 
grabbed
 if (!isMouseGrabbed && ([event modifierFlags] & 
NSEventModifierFlagCommand)) {
+/*
+ * Prevent the command key from being stuck down in the guest
+ * when using Command-F for full screen mode
+ */
+if (keycode == Q_KEY_CODE_F) {
+prevent_stuck_command_key = YES;
+}
 [NSApp sendEvent:event];
 return;
 }
-- 
2.7.2




[Qemu-devel] [PATCH v2] fpu_helper.c: fix helper_fpscr_clrbit() function

2018-06-18 Thread John Arbuckle
Fix the helper_fpscr_clrbit() function so it correctly
sets the FEX and VX bits.

Determining the value for the Floating Point Status and Control
Register's (FPSCR) FEX bit is suppose to be done like this:

FEX = (VX & VE) | (OX & OE) | (UX & UE) | (ZX & ZE) | (XX & XE))

It is described as "the logical OR of all the floating-point exception bits
masked by their respective enable bits". It was not implemented correctly. The 
value of FEX would stay on even when all other bits were set to off.

The VX bit is described as "the logical OR of all of the invalid operation 
exceptions". This bit was also not implemented correctly. It too would stay
on when all the other bits were set to off.

My main source of information is an IBM document called: 

PowerPC Microprocessor Family:
The Programming Environments for 32-Bit Microprocessors

Page 62 is where the FPSCR information is located.

This is an older copy than the one I use but it is still very useful:
https://www.pdfdrive.net/powerpc-microprocessor-family-the-programming-environments-for-32-e3087633.html

I use a G3 and G5 iMac to compare bit values with QEMU. This patch fixed all 
the problems I was having with these bits.

Signed-off-by: John Arbuckle 
---
v2 changes:
- Removed the FPSCR_VX case because it is not a bit that can be set directly.
- Replaced previous code with predefined macros fpscr_ix and fpscr_eex. 

 target/ppc/fpu_helper.c | 28 
 1 file changed, 28 insertions(+)

diff --git a/target/ppc/fpu_helper.c b/target/ppc/fpu_helper.c
index d31a933cbb..7714bfe0f9 100644
--- a/target/ppc/fpu_helper.c
+++ b/target/ppc/fpu_helper.c
@@ -325,6 +325,34 @@ void helper_fpscr_clrbit(CPUPPCState *env, uint32_t bit)
 case FPSCR_RN:
 fpscr_set_rounding_mode(env);
 break;
+case FPSCR_VXSNAN:
+case FPSCR_VXISI:
+case FPSCR_VXIDI:
+case FPSCR_VXZDZ:
+case FPSCR_VXIMZ:
+case FPSCR_VXVC:
+case FPSCR_VXSOFT:
+case FPSCR_VXSQRT:
+case FPSCR_VXCVI:
+if (!fpscr_ix) {
+/* Set VX bit to zero */
+env->fpscr &= ~(1 << FPSCR_VX);
+}
+break;
+case FPSCR_OX:
+case FPSCR_UX:
+case FPSCR_ZX:
+case FPSCR_XX:
+case FPSCR_VE:
+case FPSCR_OE:
+case FPSCR_UE:
+case FPSCR_ZE:
+case FPSCR_XE:
+if (!fpscr_eex) {
+/* Set the FEX bit */
+env->fpscr &= ~(1 << FPSCR_FEX);
+}
+break;
 default:
 break;
 }
-- 
2.14.3 (Apple Git-98)




[Qemu-devel] [PATCH] fpu_helper.c: fix helper_fpscr_clrbit() function

2018-06-17 Thread John Arbuckle
Fix the helper_fpscr_clrbit() function so it correctly
sets the FEX and VX bits.

Signed-off-by: John Arbuckle 
---
 target/ppc/fpu_helper.c | 57 +
 1 file changed, 57 insertions(+)

diff --git a/target/ppc/fpu_helper.c b/target/ppc/fpu_helper.c
index d31a933cbb..7e697a11d0 100644
--- a/target/ppc/fpu_helper.c
+++ b/target/ppc/fpu_helper.c
@@ -325,6 +325,63 @@ void helper_fpscr_clrbit(CPUPPCState *env, uint32_t bit)
 case FPSCR_RN:
 fpscr_set_rounding_mode(env);
 break;
+case FPSCR_VXSNAN:
+case FPSCR_VXISI:
+case FPSCR_VXIDI:
+case FPSCR_VXZDZ:
+case FPSCR_VXIMZ:
+case FPSCR_VXVC:
+case FPSCR_VXSOFT:
+case FPSCR_VXSQRT:
+case FPSCR_VXCVI:
+{
+int vxsnan, vxisi, vxidi, vxzdz, vximz, vxvc, vxsoft, vxsqrt, 
vxcvi;
+vxsnan = (env->fpscr >> (31 - FPSCR_VXSNAN)) & 1;
+vxisi = (env->fpscr >> (31 - FPSCR_VXISI)) & 1;
+vxidi = (env->fpscr >> (31 - FPSCR_VXIDI)) & 1;
+vxzdz = (env->fpscr >> (31 - FPSCR_VXZDZ)) & 1;
+vximz = (env->fpscr >> (31 - FPSCR_VXIMZ)) & 1;
+vxvc = (env->fpscr >> (31 - FPSCR_VXVC)) & 1;
+vxsoft = (env->fpscr >> (31 - FPSCR_VXSOFT)) & 1;
+vxsqrt = (env->fpscr >> (31 - FPSCR_VXSQRT)) & 1;
+vxcvi = (env->fpscr >> (31 - FPSCR_VXCVI)) & 1;
+if (~(vxsnan & vxisi & vxidi & vxzdz & vximz & vxvc & vxsoft &
+  vxsqrt & vxcvi)) {
+/* Set VX bit to zero */
+env->fpscr = env->fpscr & ~(1 << FPSCR_VX);
+}
+}
+break;
+case FPSCR_VX:
+case FPSCR_OX:
+case FPSCR_UX:
+case FPSCR_ZX:
+case FPSCR_XX:
+case FPSCR_VE:
+case FPSCR_OE:
+case FPSCR_UE:
+case FPSCR_ZE:
+case FPSCR_XE:
+{
+int vx, ox, ux, zx, xx, ve, oe, ue, ze, xe;
+vx = (env->fpscr >> (31 - FPSCR_VX)) & 1;
+ox = (env->fpscr >> (31 - FPSCR_OX)) & 1;
+ux = (env->fpscr >> (31 - FPSCR_UX)) & 1;
+zx = (env->fpscr >> (31 - FPSCR_ZX)) & 1;
+xx = (env->fpscr >> (31 - FPSCR_XX)) & 1;
+ve = (env->fpscr >> (31 - FPSCR_VE)) & 1;
+oe = (env->fpscr >> (31 - FPSCR_OE)) & 1;
+ue = (env->fpscr >> (31 - FPSCR_UE)) & 1;
+ze = (env->fpscr >> (31 - FPSCR_ZE)) & 1;
+xe = (env->fpscr >> (31 - FPSCR_XE)) & 1;
+bool fex;
+fex = (vx & ve) | (ox & oe) | (ux & ue) | (zx & ze) | (xx & xe);
+unsigned int mask;
+mask = (1 << FPSCR_FEX);
+/* Set the FEX bit */
+env->fpscr = (env->fpscr & ~mask) | (-fex & mask);
+}
+break;
 default:
 break;
 }
-- 
2.14.3 (Apple Git-98)




[Qemu-devel] [PATCH] ui/cocoa.m: fix absolute mode

2018-06-08 Thread John Arbuckle
Fix the cocoa front-end to correctly be able to use absolute mode.

Signed-off-by: John Arbuckle 
---
 ui/cocoa.m | 32 
 1 file changed, 24 insertions(+), 8 deletions(-)

diff --git a/ui/cocoa.m b/ui/cocoa.m
index 2991ed4f19..dda99ad638 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -350,9 +350,20 @@ - (BOOL) isOpaque
 return YES;
 }
 
-- (BOOL) screenContainsPoint:(NSPoint) p
+/* Returns YES if the host mouse cursor is in the QEMU window, NO otherwise */
+- (BOOL) mouseInWindow
 {
-return (p.x > -1 && p.x < screen.width && p.y > -1 && p.y < screen.height);
+NSPoint p = [NSEvent mouseLocation];
+BOOL return_value = NO;
+float x, y, width, height;
+x = [normalWindow frame].origin.x;
+y = [normalWindow frame].origin.y;
+width = [[normalWindow contentView] frame].size.width;
+height = [[normalWindow contentView] frame].size.height;
+if (p.x >= x && p.y >= y && p.x <= (x + width) && p.y <= (y + height)) {
+return_value = YES;
+}
+return return_value;
 }
 
 - (void) hideCursor
@@ -637,7 +648,6 @@ - (void) handleEvent:(NSEvent *)event
 int buttons = 0;
 int keycode = 0;
 bool mouse_event = false;
-NSPoint p = [event locationInWindow];
 
 switch ([event type]) {
 case NSEventTypeFlagsChanged:
@@ -738,17 +748,22 @@ - (void) handleEvent:(NSEvent *)event
 break;
 case NSEventTypeMouseMoved:
 if (isAbsoluteEnabled) {
-if (![self screenContainsPoint:p] || ![[self window] 
isKeyWindow]) {
+if ([self mouseInWindow]) {
+mouse_event = true;
+}
+
+if (![self mouseInWindow] || ![[self window] isKeyWindow]) {
 if (isMouseGrabbed) {
 [self ungrabMouse];
 }
 } else {
-if (!isMouseGrabbed) {
+if (!isMouseGrabbed && [self mouseInWindow]) {
 [self grabMouse];
 }
 }
+} else {
+mouse_event = true;
 }
-mouse_event = true;
 break;
 case NSEventTypeLeftMouseDown:
 if ([event modifierFlags] & NSEventModifierFlagCommand) {
@@ -784,7 +799,7 @@ - (void) handleEvent:(NSEvent *)event
 break;
 case NSEventTypeLeftMouseUp:
 mouse_event = true;
-if (!isMouseGrabbed && [self screenContainsPoint:p]) {
+if (!isMouseGrabbed && [self mouseInWindow]) {
 if([[self window] isKeyWindow]) {
 [self grabMouse];
 }
@@ -844,7 +859,8 @@ - (void) handleEvent:(NSEvent *)event
  * The check on screenContainsPoint is to avoid sending out of 
range values for
  * clicks in the titlebar.
  */
-if ([self screenContainsPoint:p]) {
+if ([self mouseInWindow]) {
+NSPoint p = [event locationInWindow];
 qemu_input_queue_abs(dcl->con, INPUT_AXIS_X, p.x, 0, 
screen.width);
 qemu_input_queue_abs(dcl->con, INPUT_AXIS_Y, screen.height 
- p.y, 0, screen.height);
 }
-- 
2.14.3 (Apple Git-98)




[Qemu-devel] [PATCH v2] tcg-target.inc.c: Use byte form of xgetbv instruction

2018-06-04 Thread John Arbuckle
Signed-off-by: John Arbuckle 
---
v2 changes:
- Fixed a spacing issue in the asm() function.

 tcg/i386/tcg-target.inc.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/tcg/i386/tcg-target.inc.c b/tcg/i386/tcg-target.inc.c
index 5357909fff..09141fa8e0 100644
--- a/tcg/i386/tcg-target.inc.c
+++ b/tcg/i386/tcg-target.inc.c
@@ -3501,7 +3501,11 @@ static void tcg_target_init(TCGContext *s)
sure of not hitting invalid opcode.  */
 if (c & bit_OSXSAVE) {
 unsigned xcrl, xcrh;
-asm ("xgetbv" : "=a" (xcrl), "=d" (xcrh) : "c" (0));
+/*
+ * The xgetbv instruction is not available to older versions of the
+ * assembler, so we encode the instruction manually.
+ */
+asm(".byte 0x0f, 0x01, 0xd0" : "=a" (xcrl), "=d" (xcrh) : "c" (0));
 if ((xcrl & 6) == 6) {
 have_avx1 = (c & bit_AVX) != 0;
 have_avx2 = (b7 & bit_AVX2) != 0;
-- 
2.14.3 (Apple Git-98)




[Qemu-devel] [PATCH] tcg-target.inc.c: Use byte form of xgetbv instruction

2018-06-04 Thread John Arbuckle
The assembler in most versions of Mac OS X is pretty old and does not support
the xgetbv instruction. To go around this problem the raw encoding of the
instruction is used instead.

Signed-off-by: John Arbuckle 
---
 tcg/i386/tcg-target.inc.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/tcg/i386/tcg-target.inc.c b/tcg/i386/tcg-target.inc.c
index 5357909..82e004a 100644
--- a/tcg/i386/tcg-target.inc.c
+++ b/tcg/i386/tcg-target.inc.c
@@ -3501,7 +3501,11 @@ static void tcg_target_init(TCGContext *s)
sure of not hitting invalid opcode.  */
 if (c & bit_OSXSAVE) {
 unsigned xcrl, xcrh;
-asm ("xgetbv" : "=a" (xcrl), "=d" (xcrh) : "c" (0));
+/*
+ * The xgetbv instruction is not available to older versions of 
the 
+ * assembler, so we encode the instruction manually.
+ */
+asm (".byte 0x0f, 0x01, 0xd0": "=a" (xcrl), "=d" (xcrh) : "c" (0));
 if ((xcrl & 6) == 6) {
 have_avx1 = (c & bit_AVX) != 0;
 have_avx2 = (b7 & bit_AVX2) != 0;
-- 
2.10.2




[Qemu-devel] [PATCH] ui/cocoa.m: Suppress NSFileHandlingPanelOKButton depreciation warning

2018-05-29 Thread John Arbuckle
OSX 10.13 deprecates the NSFileHandlingPanelOKButton constant, and
would rather you use NSModalResponseOK, which was introduced in OS 10.9.
Use the recommended new constant name, with a backward compatibility
define if we're building on an older OSX.

Signed-off-by: John Arbuckle 
---
 ui/cocoa.m | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/ui/cocoa.m b/ui/cocoa.m
index 110b393..c9473f0 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -79,6 +79,13 @@
 #define NSWindowStyleMaskMiniaturizable NSMiniaturizableWindowMask
 #define NSWindowStyleMaskTitled NSTitledWindowMask
 #endif
+/* 10.13 deprecates NSFileHandlingPanelOKButton in favor of
+ * NSModalResponseOK, which was introduced in 10.9. Define
+ * it for older versions.
+ */
+#if !defined MAC_OS_X_VERSION_10_9 || MAC_OS_X_VERSION_MAX_ALLOWED < 
MAC_OS_X_VERSION_10_9
+#define NSModalResponseOK NSFileHandlingPanelOKButton
+#endif
 
 //#define DEBUG
 
@@ -1218,7 +1225,7 @@ QemuCocoaView *cocoaView;
 [openPanel setCanChooseFiles: YES];
 [openPanel setAllowsMultipleSelection: NO];
 [openPanel setAllowedFileTypes: supportedImageFileTypes];
-if([openPanel runModal] == NSFileHandlingPanelOKButton) {
+if([openPanel runModal] == NSModalResponseOK) {
 NSString * file = [[[openPanel URLs] objectAtIndex: 0] path];
 if(file == nil) {
 NSBeep();
-- 
2.10.2




[Qemu-devel] [Bug 1751494] Re: tcg-target.inc.c:3495:no such instruction: `xgetbv'

2018-02-28 Thread John Arbuckle
** Summary changed:

- tag-target.inc.c:3495:no such instruction: `xgetbv'
+ tcg-target.inc.c:3495:no such instruction: `xgetbv'

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1751494

Title:
  tcg-target.inc.c:3495:no such instruction: `xgetbv'

Status in QEMU:
  New

Bug description:
  While building QEMU on Mac OS 10.6.8 I saw this error message:
  tag-target.inc.c:3495:no such instruction: `xgetbv'
  In the file tcg/i386/tcg-target.inc.c at line 3495 is where the issue is 
located. This is the problem code:
  asm ("xgetbv" : "=a" (xcrl), "=d" (xcrh) : "c" (0));

  https://github.com/asmjit/asmjit/issues/78
  According to the above link, another project also experienced this problem on 
Mac OS X. The fix was to replace the name of the instruction with the encoded 
form '.byte 0x0F, 0x01, 0xd0'. 

  Host info:
  Mac OS 10.6.8
  GCC 5.2.0

  Additional information:
  This may be a gcc issue. I have compiled QEMU on Mac OS 10.12 and didn't 
experience any issues. The compiler used was Apple's clang.

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1751494/+subscriptions



[Qemu-devel] [Bug 1751494] Re: tag-target.inc.c:3495:no such instruction: `xgetbv'

2018-02-28 Thread John Arbuckle
The exact commit that causes this problem is this:

commit 770c2fc7bb70804ae9869995fd02dadd6d7656ac
tcg/i386: Add vector operations

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1751494

Title:
  tag-target.inc.c:3495:no such instruction: `xgetbv'

Status in QEMU:
  New

Bug description:
  While building QEMU on Mac OS 10.6.8 I saw this error message:
  tag-target.inc.c:3495:no such instruction: `xgetbv'
  In the file tcg/i386/tcg-target.inc.c at line 3495 is where the issue is 
located. This is the problem code:
  asm ("xgetbv" : "=a" (xcrl), "=d" (xcrh) : "c" (0));

  https://github.com/asmjit/asmjit/issues/78
  According to the above link, another project also experienced this problem on 
Mac OS X. The fix was to replace the name of the instruction with the encoded 
form '.byte 0x0F, 0x01, 0xd0'. 

  Host info:
  Mac OS 10.6.8
  GCC 5.2.0

  Additional information:
  This may be a gcc issue. I have compiled QEMU on Mac OS 10.12 and didn't 
experience any issues. The compiler used was Apple's clang.

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1751494/+subscriptions



[Qemu-devel] [Bug 1751494] [NEW] tag-target.inc.c:3495:no such instruction: `xgetbv'

2018-02-24 Thread John Arbuckle
Public bug reported:

While building QEMU on Mac OS 10.6.8 I saw this error message:
tag-target.inc.c:3495:no such instruction: `xgetbv'
In the file tcg/i386/tcg-target.inc.c at line 3495 is where the issue is 
located. This is the problem code:
asm ("xgetbv" : "=a" (xcrl), "=d" (xcrh) : "c" (0));

https://github.com/asmjit/asmjit/issues/78
According to the above link, another project also experienced this problem on 
Mac OS X. The fix was to replace the name of the instruction with the encoded 
form '.byte 0x0F, 0x01, 0xd0'. 

Host info:
Mac OS 10.6.8
GCC 5.2.0

Additional information:
This may be a gcc issue. I have compiled QEMU on Mac OS 10.12 and didn't 
experience any issues. The compiler used was Apple's clang.

** Affects: qemu
 Importance: Undecided
 Status: New

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1751494

Title:
  tag-target.inc.c:3495:no such instruction: `xgetbv'

Status in QEMU:
  New

Bug description:
  While building QEMU on Mac OS 10.6.8 I saw this error message:
  tag-target.inc.c:3495:no such instruction: `xgetbv'
  In the file tcg/i386/tcg-target.inc.c at line 3495 is where the issue is 
located. This is the problem code:
  asm ("xgetbv" : "=a" (xcrl), "=d" (xcrh) : "c" (0));

  https://github.com/asmjit/asmjit/issues/78
  According to the above link, another project also experienced this problem on 
Mac OS X. The fix was to replace the name of the instruction with the encoded 
form '.byte 0x0F, 0x01, 0xd0'. 

  Host info:
  Mac OS 10.6.8
  GCC 5.2.0

  Additional information:
  This may be a gcc issue. I have compiled QEMU on Mac OS 10.12 and didn't 
experience any issues. The compiler used was Apple's clang.

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1751494/+subscriptions



[Qemu-devel] [PATCH v8] ui/cocoa.m: Add ability for user to specify mouse ungrab key

2018-02-20 Thread John Arbuckle
Currently the ungrab keys for the Cocoa and GTK interface are Control-Alt-g.
This combination may not be very fun for the user to have to enter, so we
now enable the user to specify their own key(s) as the ungrab key(s). The
list of keys that can be used is found in the file qapi/ui.json under QKeyCode.
The max number of keys that can be used is three.

Syntax: -display cocoa,hotkey-grab=

Example usage:  -display cocoa,hotkey-grab=home
-display cocoa,hotkey-grab=shift-ctrl
-display cocoa,hotkey-grab=ctrl-x
-display cocoa,hotkey-grab=pgup-pgdn
-display cocoa,hotkey-grab=kp_5-kp_6
-display cocoa,hotkey-grab=kp_4-kp_5-kp_6
-display cocoa,hotkey-grab=ctrl-alt

Signed-off-by: John Arbuckle <programmingk...@gmail.com>
---
v8 changes:
- Added a queue that keeps track of keys and their order for sending to the 
guest. 
- Removed send_key_if_delayed()
- Before if the user had 1-2-3 as the ungrab keys, and this happend:
down: 1
down: 2
down: 3
down: 4

What the guest would see is 'down 4' only.

Now this is what happens:

If user entered:
down: 1
down: 2
down: 3
down: 4

Guest would see:
down: 1
down: 2
down: 3
down: 4

v7 changes:
- Prevent ungrab keys from being seen by guest.

v6 changes:
- changed ungrab command-line option to -display cocoa,hotkey-grab
- Removed NSMutableSet code
- Implemented C version of Set datatype

v5 changes:
- Removed ungrab detection code from keydown event in handleEvent.
- Removed console_ungrab_sequence_length().
- Removed ability to always use the default ctrl-alt-g ungrab key sequence.
- Added ability to actually send keys to the guest that might overlap ungrab 
keys. 
Example for -ungrab ctrl-alt:
down(ctrl)
down(alt)
up(ctrl)
up(alt)
..ungrab activates..

down(ctrl)
down(alt)
down(f1)
up(ctrl)
up(alt)
up(f1)
..no ungrab activates..

v4 changes:
- Removed initialization code for key_value_array.
- Added void keyword to console_ungrab_key_sequence(),
  and console_ungrab_key_string() functions.

v3 changes:
- Added the ability for any "sendkey supported" key to be used.
- Added ability for one to three key sequences to be used.

v2 changes:
- Removed the "int i" code from the for loops. 

 include/ui/console.h |  36 
 qemu-options.hx  |   1 +
 ui/cocoa.m   |  93 ++---
 ui/console.c | 227 +++
 vl.c |  17 
 5 files changed, 362 insertions(+), 12 deletions(-)

diff --git a/include/ui/console.h b/include/ui/console.h
index 12fef80923..9d604bac92 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -508,4 +508,40 @@ static inline void early_gtk_display_init(int opengl)
 /* egl-headless.c */
 void egl_headless_init(void);
 
+/* console.c */
+/* max number of keys that can be used as the ungrab keys */
+#define MAX_UNGRAB_KEYS 3
+void set_ungrab_seq(const char *new_seq);
+int *console_ungrab_key_sequence(void);
+const char *console_ungrab_key_string(void);
+void use_default_ungrab_keys(void);
+void init_ungrab_keys(void);
+
+/* Set datatype related code */
+typedef struct Set_struct {
+int size;   /* The size of the array */
+int *array; /* The array used to store the set's values */
+} Set;
+
+Set *new_set(int max_size);
+void add_number(Set *the_set, int the_number);
+void remove_number(Set *the_set, int the_number);
+bool contains_number(Set *the_set, int the_number);
+void clear_set(Set *the_set);
+bool are_sets_equal(Set *set1, Set *set2);
+
+/* Code to handle sending keys to the guest */
+
+/* The queue is implemented as a linked list */
+struct Node {
+int value;
+void *next;
+};
+
+typedef struct Node Node;
+
+void add_key_to_queue(int keycode);
+void clear_key_queue(void);
+void send_queued_keys(DisplayChangeListener *dcl);
+
 #endif
diff --git a/qemu-options.hx b/qemu-options.hx
index 5050a49a5e..4a613e4e9c 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -1243,6 +1243,7 @@ DEF("display", HAS_ARG, QEMU_OPTION_display,
 "[,window_close=on|off][,gl=on|off]\n"
 "-display gtk[,grab_on_hover=on|off][,gl=on|off]|\n"
 "-display vnc=[,]\n"
+"-display cocoa[hotkey-grab=<key(s)>]\n"
 "-display curses\n"
 "-display none"
 "select display type\n"
diff --git a/ui/cocoa.m b/ui/cocoa.m
index 51db47cd71..c507f0d642 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -106,6 +106,8 @@
 bool stretch_video;
 NSTextField *pauseLabel;
 NSArray * supportedImageFileTypes;
+Set *key_set, *ungrab_set;
+int ungrab_sequence_length;
 
 // Mac to QKeyCode conversion
 const int mac_to_qkeycode_map[] = {
@@ -489,8 +491,6 @@ - (void) switchSurface:(DisplaySurface *)surface
 [[fullScreenWindow contentView] setFrame:[[NSScreen mainScreen] 
frame]];
 [normalWindow setFrame:NSMakeRect([normalWi

[Qemu-devel] [PATCH v7] ui/cocoa.m: Add ability for user to specify mouse ungrab key

2018-02-16 Thread John Arbuckle
Currently the ungrab keys for the Cocoa and GTK interface are Control-Alt-g.
This combination may not be very fun for the user to have to enter, so we
now enable the user to specify their own key(s) as the ungrab key(s). The
list of keys that can be used is found in the file qapi/ui.json under QKeyCode.
The max number of keys that can be used is three.

Syntax: -display cocoa,hotkey-grab=

Example usage:  -display cocoa,hotkey-grab=home
-display cocoa,hotkey-grab=shift-ctrl
-display cocoa,hotkey-grab=ctrl-x
-display cocoa,hotkey-grab=pgup-pgdn
-display cocoa,hotkey-grab=kp_5-kp_6
-display cocoa,hotkey-grab=kp_4-kp_5-kp_6
-display cocoa,hotkey-grab=ctrl-alt

Signed-off-by: John Arbuckle <programmingk...@gmail.com>
---
v7 changes:
- Prevent ungrab keys from being seen by guest.

v6 changes:
- changed ungrab command-line option to -display cocoa,hotkey-grab
- Removed NSMutableSet code
- Implemented C version of Set datatype

v5 changes:
- Removed ungrab detection code from keydown event in handleEvent.
- Removed console_ungrab_sequence_length().
- Removed ability to always use the default ctrl-alt-g ungrab key sequence.
- Added ability to actually send keys to the guest that might overlap ungrab 
keys. 
Example for -ungrab ctrl-alt:
down(ctrl)
down(alt)
up(ctrl)
up(alt)
..ungrab activates..

down(ctrl)
down(alt)
down(f1)
up(ctrl)
up(alt)
up(f1)
..no ungrab activates..

v4 changes:
- Removed initialization code for key_value_array.
- Added void keyword to console_ungrab_key_sequence(),
  and console_ungrab_key_string() functions.

v3 changes:
- Added the ability for any "sendkey supported" key to be used.
- Added ability for one to three key sequences to be used.

v2 changes:
- Removed the "int i" code from the for loops. 

 include/ui/console.h |  22 +++
 qemu-options.hx  |   1 +
 ui/cocoa.m   |  98 +
 ui/console.c | 169 +++
 vl.c |  17 ++
 5 files changed, 295 insertions(+), 12 deletions(-)

diff --git a/include/ui/console.h b/include/ui/console.h
index 12fef80923..5664b4c087 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -508,4 +508,26 @@ static inline void early_gtk_display_init(int opengl)
 /* egl-headless.c */
 void egl_headless_init(void);
 
+/* console.c */
+/* max number of keys that can be used as the ungrab keys */
+#define MAX_UNGRAB_KEYS 3
+void set_ungrab_seq(const char *new_seq);
+int *console_ungrab_key_sequence(void);
+const char *console_ungrab_key_string(void);
+void use_default_ungrab_keys(void);
+void init_ungrab_keys(void);
+
+/* Set datatype related code */
+typedef struct Set_struct {
+int size;   /* The size of the array */
+int *array; /* The array used to store the set's values */
+} Set;
+
+Set *new_set(int max_size);
+void add_number(Set *the_set, int the_number);
+void remove_number(Set *the_set, int the_number);
+bool contains_number(Set *the_set, int the_number);
+void clear_set(Set *the_set);
+bool are_sets_equal(Set *set1, Set *set2);
+
 #endif
diff --git a/qemu-options.hx b/qemu-options.hx
index 5050a49a5e..4a613e4e9c 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -1243,6 +1243,7 @@ DEF("display", HAS_ARG, QEMU_OPTION_display,
 "[,window_close=on|off][,gl=on|off]\n"
 "-display gtk[,grab_on_hover=on|off][,gl=on|off]|\n"
 "-display vnc=[,]\n"
+"-display cocoa[hotkey-grab=<key(s)>]\n"
 "-display curses\n"
 "-display none"
 "select display type\n"
diff --git a/ui/cocoa.m b/ui/cocoa.m
index 51db47cd71..a4b1f9b9f4 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -106,6 +106,8 @@
 bool stretch_video;
 NSTextField *pauseLabel;
 NSArray * supportedImageFileTypes;
+Set *key_set, *ungrab_set;
+int ungrab_sequence_length;
 
 // Mac to QKeyCode conversion
 const int mac_to_qkeycode_map[] = {
@@ -261,6 +263,15 @@ static void handleAnyDeviceErrors(Error * err)
 }
 }
 
+/* Sends any keys that were delayed because they were part of the ungrab set */
+static void send_key_if_delayed(Set *the_set, int keycode)
+{
+if (contains_number(the_set, keycode)) {
+qemu_input_event_send_key_qcode(dcl->con, keycode, true);
+qemu_input_event_send_key_qcode(dcl->con, keycode, false);
+}
+}
+
 /*
  --
 QemuCocoaView
@@ -489,8 +500,6 @@ - (void) switchSurface:(DisplaySurface *)surface
 [[fullScreenWindow contentView] setFrame:[[NSScreen mainScreen] 
frame]];
 [normalWindow setFrame:NSMakeRect([normalWindow frame].origin.x, 
[normalWindow frame].origin.y - h + oldh, w, h + [normalWindow 
frame].size.height - oldh) display:NO animate:NO];
 } else {
-if (qemu_name)
-[normalWindow 

[Qemu-devel] [PATCH v6] ui/cocoa.m: Add ability for user to specify mouse ungrab key

2018-02-03 Thread John Arbuckle
Currently the ungrab keys for the Cocoa and GTK interface are Control-Alt-g.
This combination may not be very fun for the user to have to enter, so we
now enable the user to specify their own key(s) as the ungrab key(s). The
list of keys that can be used is found in the file qapi/ui.json under QKeyCode.
The max number of keys that can be used is three.

Syntax: -display cocoa,hotkey-grab=

Example usage:  -display cocoa,hotkey-grab=home
-display cocoa,hotkey-grab=shift-ctrl
-display cocoa,hotkey-grab=ctrl-x
-display cocoa,hotkey-grab=pgup-pgdn
-display cocoa,hotkey-grab=kp_5-kp_6
-display cocoa,hotkey-grab=kp_4-kp_5-kp_6
-display cocoa,hotkey-grab=ctrl-alt

Signed-off-by: John Arbuckle <programmingk...@gmail.com>
---
v6 changes:
- changed ungrab command-line option to -display cocoa,hotkey-grab
- Removed NSMutableSet code
- Implemented C version of Set datatype


v5 changes:
- Removed ungrab detection code from keydown event in handleEvent.
- Removed console_ungrab_sequence_length().
- Removed ability to always use the default ctrl-alt-g ungrab key sequence.
- Added ability to actually send keys to the guest that might overlap ungrab 
keys. 
Example for -ungrab ctrl-alt:
down(ctrl)
down(alt)
up(ctrl)
up(alt)
..ungrab activates..

down(ctrl)
down(alt)
down(f1)
up(ctrl)
up(alt)
up(f1)
..no ungrab activates..

v4 changes:
- Removed initialization code for key_value_array.
- Added void keyword to console_ungrab_key_sequence(),
  and console_ungrab_key_string() functions.

v3 changes:
- Added the ability for any "sendkey supported" key to be used.
- Added ability for one to three key sequences to be used.

v2 changes:
- Removed the "int i" code from the for loops. 

 include/ui/console.h |  22 +++
 qemu-options.hx  |   1 +
 ui/cocoa.m   |  80 
 ui/console.c | 169 +++
 vl.c |  17 ++
 5 files changed, 277 insertions(+), 12 deletions(-)

diff --git a/include/ui/console.h b/include/ui/console.h
index 7b35778444..4f5a881533 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -533,4 +533,26 @@ static inline void early_gtk_display_init(int opengl)
 /* egl-headless.c */
 void egl_headless_init(void);
 
+/* console.c */
+/* max number of keys that can be used as the ungrab keys */
+#define MAX_UNGRAB_KEYS 3
+void set_ungrab_seq(const char *new_seq);
+int *console_ungrab_key_sequence(void);
+const char *console_ungrab_key_string(void);
+void use_default_ungrab_keys(void);
+void init_ungrab_keys(void);
+
+/* Set datatype related code */
+typedef struct Set_struct {
+int size;   /* The size of the array */
+int *array; /* The array used to store the set's values */
+} Set;
+
+Set *new_set(int max_size);
+void add_number(Set *the_set, int the_number);
+void remove_number(Set *the_set, int the_number);
+bool contains_number(Set *the_set, int the_number);
+void clear_set(Set *the_set);
+bool are_sets_equal(Set *set1, Set *set2);
+
 #endif
diff --git a/qemu-options.hx b/qemu-options.hx
index 8ce427da78..878a4d5867 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -1243,6 +1243,7 @@ DEF("display", HAS_ARG, QEMU_OPTION_display,
 "[,window_close=on|off][,gl=on|off]\n"
 "-display gtk[,grab_on_hover=on|off][,gl=on|off]|\n"
 "-display vnc=[,]\n"
+"-display cocoa[hotkey-grab=<key(s)>]\n"
 "-display curses\n"
 "-display none"
 "select display type\n"
diff --git a/ui/cocoa.m b/ui/cocoa.m
index 6be9848391..097c7fd4ce 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -105,6 +105,8 @@
 bool stretch_video;
 NSTextField *pauseLabel;
 NSArray * supportedImageFileTypes;
+Set *key_set, *ungrab_set;
+int ungrab_sequence_length;
 
 // Mac to QKeyCode conversion
 const int mac_to_qkeycode_map[] = {
@@ -488,8 +490,6 @@ - (void) switchSurface:(DisplaySurface *)surface
 [[fullScreenWindow contentView] setFrame:[[NSScreen mainScreen] 
frame]];
 [normalWindow setFrame:NSMakeRect([normalWindow frame].origin.x, 
[normalWindow frame].origin.y - h + oldh, w, h + [normalWindow 
frame].size.height - oldh) display:NO animate:NO];
 } else {
-if (qemu_name)
-[normalWindow setTitle:[NSString stringWithFormat:@"QEMU %s", 
qemu_name]];
 [normalWindow setFrame:NSMakeRect([normalWindow frame].origin.x, 
[normalWindow frame].origin.y - h + oldh, w, h + [normalWindow 
frame].size.height - oldh) display:YES animate:NO];
 }
 
@@ -669,14 +669,29 @@ - (void) handleEvent:(NSEvent *)event
 if (keycode == Q_KEY_CODE_CAPS_LOCK ||
 keycode == Q_KEY_CODE_NUM_LOCK) {
 [self toggleStatefulModifier:keycode];
-   

[Qemu-devel] [PATCH v2] hw/audio/sb16.c: change dolog() to qemu_log_mask()

2018-02-01 Thread John Arbuckle
Changes all the occurrances of dolog() to qemu_log_mask().

Signed-off-by: John Arbuckle <programmingk...@gmail.com>
---
v2 changes:
Removed several replaces of dolog() to qemu_log_mask().
Added one error_setg() call.

 hw/audio/sb16.c | 79 +++--
 1 file changed, 43 insertions(+), 36 deletions(-)

diff --git a/hw/audio/sb16.c b/hw/audio/sb16.c
index 6ab2f6f89a..31de264ab7 100644
--- a/hw/audio/sb16.c
+++ b/hw/audio/sb16.c
@@ -29,6 +29,8 @@
 #include "hw/qdev.h"
 #include "qemu/timer.h"
 #include "qemu/host-utils.h"
+#include "qemu/log.h"
+#include "qapi/error.h"
 
 #define dolog(...) AUD_log ("sb16", __VA_ARGS__)
 
@@ -123,7 +125,7 @@ static int magic_of_irq (int irq)
 case 10:
 return 8;
 default:
-dolog ("bad irq %d\n", irq);
+qemu_log_mask(LOG_GUEST_ERROR, "bad irq %d\n", irq);
 return 2;
 }
 }
@@ -140,7 +142,7 @@ static int irq_of_magic (int magic)
 case 8:
 return 10;
 default:
-dolog ("bad irq magic %d\n", magic);
+qemu_log_mask(LOG_GUEST_ERROR, "bad irq magic %d\n", magic);
 return -1;
 }
 }
@@ -258,8 +260,8 @@ static void dma_cmd8 (SB16State *s, int mask, int dma_len)
 s->align = (1 << s->fmt_stereo) - 1;
 
 if (s->block_size & s->align) {
-dolog ("warning: misaligned block size %d, alignment %d\n",
-   s->block_size, s->align + 1);
+qemu_log_mask(LOG_GUEST_ERROR, "warning: misaligned block size %d,"
+  " alignment %d\n", s->block_size, s->align + 1);
 }
 
 ldebug ("freq %d, stereo %d, sign %d, bits %d, "
@@ -338,8 +340,8 @@ static void dma_cmd (SB16State *s, uint8_t cmd, uint8_t d0, 
int dma_len)
 s->highspeed = 0;
 s->align = (1 << (s->fmt_stereo + (s->fmt_bits == 16))) - 1;
 if (s->block_size & s->align) {
-dolog ("warning: misaligned block size %d, alignment %d\n",
-   s->block_size, s->align + 1);
+qemu_log_mask(LOG_GUEST_ERROR, "warning: misaligned block size %d,"
+  " alignment %d\n", s->block_size, s->align + 1);
 }
 
 if (s->freq) {
@@ -391,7 +393,8 @@ static void command (SB16State *s, uint8_t cmd)
 
 if (cmd > 0xaf && cmd < 0xd0) {
 if (cmd & 8) {
-dolog ("ADC not yet supported (command %#x)\n", cmd);
+qemu_log_mask(LOG_UNIMP, "ADC not yet supported (command %#x)\n",
+  cmd);
 }
 
 switch (cmd >> 4) {
@@ -399,7 +402,7 @@ static void command (SB16State *s, uint8_t cmd)
 case 12:
 break;
 default:
-dolog ("%#x wrong bits\n", cmd);
+qemu_log_mask(LOG_GUEST_ERROR, "%#x wrong bits\n", cmd);
 }
 s->needed_bytes = 3;
 }
@@ -453,7 +456,7 @@ static void command (SB16State *s, uint8_t cmd)
 goto warn;
 
 case 0x35:
-dolog ("0x35 - MIDI command not implemented\n");
+qemu_log_mask(LOG_UNIMP, "0x35 - MIDI command not implemented\n");
 break;
 
 case 0x40:
@@ -487,34 +490,38 @@ static void command (SB16State *s, uint8_t cmd)
 
 case 0x74:
 s->needed_bytes = 2; /* DMA DAC, 4-bit ADPCM */
-dolog ("0x75 - DMA DAC, 4-bit ADPCM not implemented\n");
+qemu_log_mask(LOG_UNIMP, "0x75 - DMA DAC, 4-bit ADPCM not"
+  " implemented\n");
 break;
 
 case 0x75:  /* DMA DAC, 4-bit ADPCM Reference */
 s->needed_bytes = 2;
-dolog ("0x74 - DMA DAC, 4-bit ADPCM Reference not implemented\n");
+qemu_log_mask(LOG_UNIMP, "0x74 - DMA DAC, 4-bit ADPCM Reference 
not"
+  " implemented\n");
 break;
 
 case 0x76:  /* DMA DAC, 2.6-bit ADPCM */
 s->needed_bytes = 2;
-dolog ("0x74 - DMA DAC, 2.6-bit ADPCM not implemented\n");
+qemu_log_mask(LOG_UNIMP, "0x74 - DMA DAC, 2.6-bit ADPCM not"
+  " implemented\n");
 break;
 
 case 0x77:  /* DMA DAC, 2.6-bit ADPCM Reference */
 s->needed_bytes = 2;
-dolog ("0x74 - DMA DAC, 2.6-bit ADPCM Reference not 
implemented\n");
+qemu_log_mask(LOG_UNIMP, "0x74 - DMA DAC, 2.6-bit ADPCM Reference"
+  " not implemented\n");
 break;
 
 case 0x7d:
-dolog ("0x7d - Autio-

[Qemu-devel] [PATCH] hw/audio/sb16.c: change dolog() to qemu_log_mask()

2018-02-01 Thread John Arbuckle
Changes all the occurrances of dolog() to qemu_log_mask().

Signed-off-by: John Arbuckle <programmingk...@gmail.com>
---
 hw/audio/sb16.c | 105 
 1 file changed, 53 insertions(+), 52 deletions(-)

diff --git a/hw/audio/sb16.c b/hw/audio/sb16.c
index 6ab2f6f89a..d32c568650 100644
--- a/hw/audio/sb16.c
+++ b/hw/audio/sb16.c
@@ -29,6 +29,7 @@
 #include "hw/qdev.h"
 #include "qemu/timer.h"
 #include "qemu/host-utils.h"
+#include "qemu/log.h"
 
 #define dolog(...) AUD_log ("sb16", __VA_ARGS__)
 
@@ -123,7 +124,7 @@ static int magic_of_irq (int irq)
 case 10:
 return 8;
 default:
-dolog ("bad irq %d\n", irq);
+qemu_log_mask(LOG_UNIMP, "bad irq %d\n", irq);
 return 2;
 }
 }
@@ -140,7 +141,7 @@ static int irq_of_magic (int magic)
 case 8:
 return 10;
 default:
-dolog ("bad irq magic %d\n", magic);
+qemu_log_mask(LOG_UNIMP, "bad irq magic %d\n", magic);
 return -1;
 }
 }
@@ -258,8 +259,8 @@ static void dma_cmd8 (SB16State *s, int mask, int dma_len)
 s->align = (1 << s->fmt_stereo) - 1;
 
 if (s->block_size & s->align) {
-dolog ("warning: misaligned block size %d, alignment %d\n",
-   s->block_size, s->align + 1);
+qemu_log_mask(LOG_UNIMP, "warning: misaligned block size %d, alignment"
+  " %d\n", s->block_size, s->align + 1);
 }
 
 ldebug ("freq %d, stereo %d, sign %d, bits %d, "
@@ -338,8 +339,8 @@ static void dma_cmd (SB16State *s, uint8_t cmd, uint8_t d0, 
int dma_len)
 s->highspeed = 0;
 s->align = (1 << (s->fmt_stereo + (s->fmt_bits == 16))) - 1;
 if (s->block_size & s->align) {
-dolog ("warning: misaligned block size %d, alignment %d\n",
-   s->block_size, s->align + 1);
+qemu_log_mask(LOG_UNIMP, "warning: misaligned block size %d, alignment"
+  " %d\n", s->block_size, s->align + 1);
 }
 
 if (s->freq) {
@@ -380,7 +381,7 @@ static inline uint8_t dsp_get_data (SB16State *s)
 return s->in2_data[--s->in_index];
 }
 else {
-dolog ("buffer underflow\n");
+qemu_log_mask(LOG_UNIMP, "buffer underflow\n");
 return 0;
 }
 }
@@ -391,7 +392,8 @@ static void command (SB16State *s, uint8_t cmd)
 
 if (cmd > 0xaf && cmd < 0xd0) {
 if (cmd & 8) {
-dolog ("ADC not yet supported (command %#x)\n", cmd);
+qemu_log_mask(LOG_UNIMP, "ADC not yet supported (command %#x)\n",
+  cmd);
 }
 
 switch (cmd >> 4) {
@@ -399,7 +401,7 @@ static void command (SB16State *s, uint8_t cmd)
 case 12:
 break;
 default:
-dolog ("%#x wrong bits\n", cmd);
+qemu_log_mask(LOG_UNIMP, "%#x wrong bits\n", cmd);
 }
 s->needed_bytes = 3;
 }
@@ -453,7 +455,7 @@ static void command (SB16State *s, uint8_t cmd)
 goto warn;
 
 case 0x35:
-dolog ("0x35 - MIDI command not implemented\n");
+qemu_log_mask(LOG_UNIMP, "0x35 - MIDI command not implemented\n");
 break;
 
 case 0x40:
@@ -487,34 +489,38 @@ static void command (SB16State *s, uint8_t cmd)
 
 case 0x74:
 s->needed_bytes = 2; /* DMA DAC, 4-bit ADPCM */
-dolog ("0x75 - DMA DAC, 4-bit ADPCM not implemented\n");
+qemu_log_mask(LOG_UNIMP, "0x75 - DMA DAC, 4-bit ADPCM not"
+  " implemented\n");
 break;
 
 case 0x75:  /* DMA DAC, 4-bit ADPCM Reference */
 s->needed_bytes = 2;
-dolog ("0x74 - DMA DAC, 4-bit ADPCM Reference not implemented\n");
+qemu_log_mask(LOG_UNIMP, "0x74 - DMA DAC, 4-bit ADPCM Reference 
not"
+  " implemented\n");
 break;
 
 case 0x76:  /* DMA DAC, 2.6-bit ADPCM */
 s->needed_bytes = 2;
-dolog ("0x74 - DMA DAC, 2.6-bit ADPCM not implemented\n");
+qemu_log_mask(LOG_UNIMP, "0x74 - DMA DAC, 2.6-bit ADPCM not"
+  " implemented\n");
 break;
 
 case 0x77:  /* DMA DAC, 2.6-bit ADPCM Reference */
 s->needed_bytes = 2;
-dolog ("0x74 - DMA DAC, 2.6-bit ADPCM Reference not 
implemented\n");
+qemu_log_mask(LOG_UNIMP, "0x74 - DMA DAC, 2.6-bit ADPCM Reference"
+  " not imple

[Qemu-devel] [PATCH] hw/audio/sb16.c: Convert file to new logging API

2018-01-29 Thread John Arbuckle
Use the qemu_log_mask() function to log messages.

Signed-off-by: John Arbuckle <programmingk...@gmail.com>
---
 hw/audio/sb16.c | 221 
 1 file changed, 112 insertions(+), 109 deletions(-)

diff --git a/hw/audio/sb16.c b/hw/audio/sb16.c
index 6ab2f6f89a..bdb79aeafa 100644
--- a/hw/audio/sb16.c
+++ b/hw/audio/sb16.c
@@ -29,18 +29,12 @@
 #include "hw/qdev.h"
 #include "qemu/timer.h"
 #include "qemu/host-utils.h"
+#include "qemu/log.h"
 
-#define dolog(...) AUD_log ("sb16", __VA_ARGS__)
 
 /* #define DEBUG */
 /* #define DEBUG_SB16_MOST */
 
-#ifdef DEBUG
-#define ldebug(...) dolog (__VA_ARGS__)
-#else
-#define ldebug(...)
-#endif
-
 static const char e3[] = "COPYRIGHT (C) CREATIVE TECHNOLOGY LTD, 1992.";
 
 #define TYPE_SB16 "sb16"
@@ -123,7 +117,7 @@ static int magic_of_irq (int irq)
 case 10:
 return 8;
 default:
-dolog ("bad irq %d\n", irq);
+qemu_log_mask(LOG_UNIMP, "bad irq %d\n", irq);
 return 2;
 }
 }
@@ -140,7 +134,7 @@ static int irq_of_magic (int magic)
 case 8:
 return 10;
 default:
-dolog ("bad irq magic %d\n", magic);
+qemu_log_mask(LOG_UNIMP, "bad irq magic %d\n", magic);
 return -1;
 }
 }
@@ -148,15 +142,16 @@ static int irq_of_magic (int magic)
 #if 0
 static void log_dsp (SB16State *dsp)
 {
-ldebug ("%s:%s:%d:%s:dmasize=%d:freq=%d:const=%d:speaker=%d\n",
-dsp->fmt_stereo ? "Stereo" : "Mono",
-dsp->fmt_signed ? "Signed" : "Unsigned",
-dsp->fmt_bits,
-dsp->dma_auto ? "Auto" : "Single",
-dsp->block_size,
-dsp->freq,
-dsp->time_const,
-dsp->speaker);
+qemu_log_mask(LOG_UNIMP, "%s:%s:%d:%s:dmasize=%d:freq=%d:const=%d:"
+  "speaker=%d\n",
+  dsp->fmt_stereo ? "Stereo" : "Mono",
+  dsp->fmt_signed ? "Signed" : "Unsigned",
+  dsp->fmt_bits,
+  dsp->dma_auto ? "Auto" : "Single",
+  dsp->block_size,
+  dsp->freq,
+  dsp->time_const,
+  dsp->speaker);
 }
 #endif
 
@@ -173,7 +168,8 @@ static void control (SB16State *s, int hold)
 IsaDmaClass *k = ISADMA_GET_CLASS(isa_dma);
 s->dma_running = hold;
 
-ldebug ("hold %d high %d dma %d\n", hold, s->use_hdma, dma);
+qemu_log_mask(LOG_UNIMP, "hold %d high %d dma %d\n", hold, s->use_hdma,
+  dma);
 
 if (hold) {
 k->hold_DREQ(isa_dma, dma);
@@ -258,14 +254,14 @@ static void dma_cmd8 (SB16State *s, int mask, int dma_len)
 s->align = (1 << s->fmt_stereo) - 1;
 
 if (s->block_size & s->align) {
-dolog ("warning: misaligned block size %d, alignment %d\n",
-   s->block_size, s->align + 1);
+qemu_log_mask(LOG_UNIMP, "warning: misaligned block size %d, alignment"
+  " %d\n", s->block_size, s->align + 1);
 }
 
-ldebug ("freq %d, stereo %d, sign %d, bits %d, "
-"dma %d, auto %d, fifo %d, high %d\n",
-s->freq, s->fmt_stereo, s->fmt_signed, s->fmt_bits,
-s->block_size, s->dma_auto, s->fifo, s->highspeed);
+qemu_log_mask(LOG_UNIMP, "freq %d, stereo %d, sign %d, bits %d, "
+  "dma %d, auto %d, fifo %d, high %d\n",
+  s->freq, s->fmt_stereo, s->fmt_signed, s->fmt_bits,
+  s->block_size, s->dma_auto, s->fifo, s->highspeed);
 
 continue_dma8 (s);
 speaker (s, 1);
@@ -310,10 +306,10 @@ static void dma_cmd (SB16State *s, uint8_t cmd, uint8_t 
d0, int dma_len)
 s->block_size <<= s->fmt_stereo;
 }
 
-ldebug ("freq %d, stereo %d, sign %d, bits %d, "
-"dma %d, auto %d, fifo %d, high %d\n",
-s->freq, s->fmt_stereo, s->fmt_signed, s->fmt_bits,
-s->block_size, s->dma_auto, s->fifo, s->highspeed);
+qemu_log_mask(LOG_UNIMP, "freq %d, stereo %d, sign %d, bits %d, "
+  "dma %d, auto %d, fifo %d, high %d\n",
+  s->freq, s->fmt_stereo, s->fmt_signed, s->fmt_bits,
+  s->block_size, s->dma_auto, s->fifo, s->highspeed);
 
 if (16 == s->fmt_bits) {
 if (s->fmt_signed) {
@@ -338,8 +334,8 @@ static void dma_cmd (SB16State *s, uint8_t cmd, uint8_t d0, 
int dma_len)
 s->highspeed = 0;
 s-

[Qemu-devel] [PATCH] Only print unknown command message in debug mode

2018-01-29 Thread John Arbuckle
After using QEMU with the sb16 sound card I would see all these messages about 
some numbered command not being understood. It became annoying after a while to 
always see this message, so this patch changes things so that the message is 
only printed when DEBUG is defined. 

Signed-off-by: John Arbuckle <programmingk...@gmail.com>
---
 hw/audio/sb16.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/audio/sb16.c b/hw/audio/sb16.c
index 6ab2f6f89a..45b679c4df 100644
--- a/hw/audio/sb16.c
+++ b/hw/audio/sb16.c
@@ -632,7 +632,7 @@ static void command (SB16State *s, uint8_t cmd)
 return;
 
  warn:
-dolog ("warning: command %#x,%d is not truly understood yet\n",
+ldebug("warning: command %#x,%d is not truly understood yet\n",
cmd, s->needed_bytes);
 goto exit;
 
-- 
2.14.3 (Apple Git-98)




Re: [Qemu-devel] [Bug 1737194] Windows NT 4.0 fails to boot from qcow2 installation

2018-01-26 Thread John Arbuckle
I have installed Windows 95 OSR 2.5 in QEMU using the qcow2 format. So
far there hasn't been any major problems that prevent Windows from
booting.

I downloaded the ISO file from here:
https://winworldpc.com/product/windows-95/osr-3

Used this floppy boot image to boot QEMU: https://winworldpc.com/product
/microsoft-windows-boot-disk/95-osr2x

Created the hard drive image file like this: qemu-img create -f qcow2
~/windows95.qcow2 2G

I used my Windows XP VM to format this qcow2 file to the FAT format.

My first attempt to boot the hard drive image file failed probably
because the CPU was set to something Windows 95 couldn't handle
properly. Changing the cpu to a pentium removed the booting problem.

This is the command-line I used to boot Windows 95:
qemu-system-i386 -hda windows95.qcow2 -boot c -netdev user,id=mynet0 -device 
ne2k_isa,netdev=mynet0 -soundhw sb16 -m 32 -cpu pentium -vga cirrus -localtime 

The version of QEMU I used is today's git version (commit
e607bbee553cfe73072870cef458cfa4e78133e2).

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1737194

Title:
  Windows NT 4.0 fails to boot from qcow2 installation

Status in QEMU:
  New

Bug description:
  Windows NT 4.0 will not boot from an installation more than once if
  installed in a qcow2 image file. A quick fix to this problem is to use
  the qcow format instead.

  Steps to reproduce this issue:

  Create the image file:
  qemu-img create -f qcow2 winnt4.qcow2 1G

  Boot from a Windows NT 4.0 Workstation CD:
  qemu-system-i386 -hda winnt4.qcow2 -cdrom /dev/cdrom -boot d -m 128 -cpu 
pentium -vga cirrus

  During the installation process you have the choise between FAT and
  NTFS. You can pick anyone.

  After finishing the installation the guest will reboot to install
  additional items. Once this is done the guest will be bootable. Eject
  any CD media from QEMU and reboot. You will then see Windows NT 4.0
  booting up to the desktop. Go to "Start->Shut down" to shut down. Then
  when Windows is ready quit QEMU.

  Now try to boot using this command:
  qemu-system-i386 -hda winnt4.qcow2 -boot c -m 128 -cpu pentium -vga cirrus 
   
  The BIOS screen will display an error message:

  For NTFS: 
  Booting from Hard Disk...
  A disk read error occurred.
  Insert a system diskette and restart
  the system.

  For FAT:
  No bootable device.

  Additional information:
  qemu-system-i386 version: 2.10.1
  qemu-img version: 2.10.92 (v2.11.0-rc4-dirty)

  If you don't have a Windows NT 4.0 Workstation installation CD, you may 
download one from here:
  https://winworldpc.com/product/windows-nt-40/40

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1737194/+subscriptions



[Qemu-devel] [PATCH v5] cocoa.m: Add ability for user to specify mouse ungrab key

2018-01-26 Thread John Arbuckle
Currently the ungrab keys for the Cocoa and GTK interface are Control-Alt-g.
This combination may not be very fun for the user to have to enter, so we
now enable the user to specify their own key(s) as the ungrab key(s). The
list of keys that can be used is found in the file qapi/ui.json under QKeyCode.
The max number of keys that can be used is three.

Syntax: -ungrab 

Example usage:  -ungrab home
-ungrab shift-ctrl
-ungrab ctrl-x
-ungrab pgup-pgdn
-ungrab kp_5-kp_6
-ungrab kp_4-kp_5-kp_6
-ungrab ctrl-alt

Signed-off-by: John Arbuckle <programmingk...@gmail.com>
---
v5 changes:
- Removed ungrab detection code from keydown event in handleEvent.
- Removed console_ungrab_sequence_length().
- Removed ability to always use the default ctrl-alt-g ungrab key sequence.
- Added ability to actually send keys to the guest that might overlap ungrab 
keys. 
Example for -ungrab ctrl-alt:
down(ctrl)
down(alt)
up(ctrl)
up(alt)
..ungrab activates..

down(ctrl)
down(alt)
down(f1)
up(ctrl)
up(alt)
up(f1)
..no ungrab activates..

v4 changes:
- Removed initialization code for key_value_array.
- Added void keyword to console_ungrab_key_sequence(),
  and console_ungrab_key_string() functions.

v3 changes:
- Added the ability for any "sendkey supported" key to be used.
- Added ability for one to three key sequences to be used.

v2 changes:
- Removed the "int i" code from the for loops. 

 include/ui/console.h |   8 
 qemu-options.hx  |   2 +
 ui/cocoa.m   | 109 +--
 ui/console.c |  62 +
 vl.c |   3 ++
 5 files changed, 173 insertions(+), 11 deletions(-)

diff --git a/include/ui/console.h b/include/ui/console.h
index 580dfc57ee..f346cb05d0 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -534,4 +534,12 @@ static inline void early_gtk_display_init(int opengl)
 /* egl-headless.c */
 void egl_headless_init(void);
 
+/* console.c */
+/* max number of keys that can be used as the ungrab keys */
+#define MAX_UNGRAB_KEYS 3
+void set_ungrab_seq(const char *new_seq);
+int *console_ungrab_key_sequence(void);
+const char *console_ungrab_key_string(void);
+void use_default_ungrab_keys(void);
+void init_ungrab_keys(void);
 #endif
diff --git a/qemu-options.hx b/qemu-options.hx
index 678181c599..5ba66905f5 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -4251,6 +4251,8 @@ contents of @code{iv.b64} to the second secret
 
 ETEXI
 
+DEF("ungrab", HAS_ARG, QEMU_OPTION_ungrab, \
+"-ungrab ", QEMU_ARCH_ALL)
 
 HXCOMM This is the last statement. Insert new options before this line!
 STEXI
diff --git a/ui/cocoa.m b/ui/cocoa.m
index 330ccebf90..1dc9b23941 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -105,6 +105,8 @@
 bool stretch_video;
 NSTextField *pauseLabel;
 NSArray * supportedImageFileTypes;
+NSMutableSet *key_set, *ungrab_set;
+int ungrab_sequence_length;
 
 // Mac to QKeyCode conversion
 const int mac_to_qkeycode_map[] = {
@@ -303,6 +305,7 @@ - (float) cdx;
 - (float) cdy;
 - (QEMUScreen) gscreen;
 - (void) raiseAllKeys;
+- (BOOL) is_ungrab_seq;
 @end
 
 QemuCocoaView *cocoaView;
@@ -488,8 +491,6 @@ - (void) switchSurface:(DisplaySurface *)surface
 [[fullScreenWindow contentView] setFrame:[[NSScreen mainScreen] 
frame]];
 [normalWindow setFrame:NSMakeRect([normalWindow frame].origin.x, 
[normalWindow frame].origin.y - h + oldh, w, h + [normalWindow 
frame].size.height - oldh) display:NO animate:NO];
 } else {
-if (qemu_name)
-[normalWindow setTitle:[NSString stringWithFormat:@"QEMU %s", 
qemu_name]];
 [normalWindow setFrame:NSMakeRect([normalWindow frame].origin.x, 
[normalWindow frame].origin.y - h + oldh, w, h + [normalWindow 
frame].size.height - oldh) display:YES animate:NO];
 }
 
@@ -669,14 +670,29 @@ - (void) handleEvent:(NSEvent *)event
 if (keycode == Q_KEY_CODE_CAPS_LOCK ||
 keycode == Q_KEY_CODE_NUM_LOCK) {
 [self toggleStatefulModifier:keycode];
-} else if (qemu_console_is_graphic(NULL)) {
+} else {
   [self toggleModifier:keycode];
 }
 }
 
+/*
+ * This code has to be here because the user might use a modifier
+ * key like shift as an ungrab key.
+ */
+if (modifiers_state[keycode] == YES) { // if the key is down
+[self check_key: keycode];
+} else {   // if the key is up
+if ([self is_ungrab_seq] == YES) {
+[self ungrabMouse];
+[self clear_ungrab_array];
+return;
+}
+[self remove_key_from_ungrab_array: keycode];
+}
 break

Re: [Qemu-devel] [Bug 1737194] Re: Windows NT 4.0 fails to boot from qcow2 installation

2018-01-26 Thread John Arbuckle
> On Jan 26, 2018, at 9:51 AM, David Lindsay  wrote:
> 
> Hi John & others:
> 
> (3 separate things.)
> 
> 1: Image formats
> 
> Regarding qcow, unfortunately there is no change if I use this format.
> 
> - Windows 3.1 initially hung at "Starting MS-DOS..."; upon restart it
> crashed when it decided it couldn't find COMMAND.COM (a frequent failure
> mode I forgot to mention).

I have tried using Windows 3.1 in QEMU in the past. It was a long time
ago so I will have to go back and try it again. Hopefully one of the
files here would help: https://winworldpc.com/product/windows-3/31

> 
> - NT initially crashed with one of its famous disk read errors. Of
> course.
> 
> - After the initial NT crash, repeated QEMU reloads began showing the
> boot menu rather consistently, so I pointed my test harness to the qcow
> image. Of course, it crashed on the first try in the test harness :),
> then launched successfully 42 times before crashing again. This sort of
> behavior is pretty consistent with what happened with raw images.
> 
> I just did 77 runs with commit 306ec6c and the qcow image worked just as
> well as the raw image did.

Have you tried the latest commit or release of QEMU yet?

> It could be strongly argued that I should create _new_ disk images. But
> my three counter-arguments are that
> 
> a) the storage format shouldn't influence the guest.

This is what I thought. But this is just a theory. It doesn't work in
real life.

> b) I exhaustively tested the bisection point I found, and the "before" state 
> is absolutely rock solid. I'd say I've tested 450+ consecutive good runs 
> without any hitches at this point - the 350 runs I documented, and a hundred 
> or so more that I did before that.
> c) it could be very well argued that QEMU-level errors have left corruption 
> in the disk image. My argument here is to reiterate (b).
> 
> If anyone wants to strongly argue for creating new images, I can try
> that. *resigned grumble*
> 
> Also... is qcow working stably for you, with no issues? If it is I'm
> very fascinated to hear that.

That is correct. I went back to QEMU 0.9 and tried a bunch of releases
to around 2.x until I realized it was the image file that was the
problem. I must have installed Windows NT 4.0 around 20 times before
finding the answer to my problem.

> And - you're using `-M isapc`, right? I find that if I don't, NT will
> hit a STOP error pretty much instantaneously (within the first few
> fractions of a second after it's obvious the kernel has initialized).

Actually I like using the PCI network cards so I never had a reason to
use "-M isapc" until you contacted me. Windows NT 4.0 runs rock solid
for me without it. The only issue I noticed is when I play StarCraft in
my Windows NT 4.0 VM, the mouse starts moving around erratically after
around 45 minutes of use.


> 2: Bitness
> 
> The few error messages I saw in your build failure hinted at 64-bit
> incompatibility.
> 
> Well... I was able, at length, to get QEMU to build for 32-bit. It
> mostly boiled down to careful analysis of config-host.mak, removing -m64
> and substituting -m32, and poking {C,LD}FLAGS until it compiled.
> 
> As I noted in the other thread, the built QEMU had a 100% broken TCG and
> required some form of hardware acceleration to even start correctly. In
> my case this was KVM.

I'm not too sure about 32-bit host support. All my QEMU-running
computers are 64-bit. If you have figured out how to fix these problems
making patch and sending it in would probably help a lot of people. Let
me know if you need help doing this.

> 
> 3: Bisection
> 
> I initially thought to cram this info somewhere in the I/O report but
> decided against it due to that post's final length. But it could be
> relevant here.
> 
> Here's the approach I used to rapidly bounce back and forth and in
> search of the before-and-after "edges". I used this for the I/O issues
> discussed here and also for another issue
> (https://bugs.launchpad.net/qemu/+bug/1745316), and if you feel like it,
> you could use this to track down why the older QEMU versions are not
> building on OS X.

The thing is if the newest versions of QEMU work, why try debugging an
older version?

> 
> This could be worth it - the fixes could be minimal and a hacky "good
> enough" backport could be viable, or this may just end up confirming
> that the breakage was major.
> 
> I'll just document the exact workflow I used.



> It's kind of meditative... but it does get irritating toward the end
> when you're jumping forward by 30... then back by 7... then forward by
> 3... (like an annoying padlock!)

'git bisect' is a lot easier to use. It does most of the work for you.



> Even with a starting list of nearly 30k commits, this works
> exponentially at best, and better-than-exponentially if you decide to
> arbitrarily jump back or forward by more than half. So while this isn't
> a 10-minute job, it _shouldn't_ take all day, either.

Sorry I couldn't help with 

Re: [Qemu-devel] [Bug 1737194] Re: Windows NT 4.0 fails to boot from qcow2 installation

2018-01-25 Thread John Arbuckle
> On Jan 25, 2018, at 11:16 AM, Peter Maydell <peter.mayd...@linaro.org> wrote:
> 
> On 25 January 2018 at 15:58, John Arbuckle <programmingk...@gmail.com> wrote:
>> I did try to build at commits 306ec6c3cece7004429c79c1ac93d49919f1f1cc
>> and e689f7c668cbd9d08f330e17c3dd3a059c9553d3. Both failed to build on my
>> Mac OS X system. Here is the error message I usually saw:
>> 
>>  LINK  qemu-io
>> Undefined symbols for architecture x86_64:
>>  "_use_rt_clock", referenced from:
>>  _bdrv_acct_start in block.o
>>  _bdrv_acct_done in block.o
>> Undefined symbols for architecture x86_64:
>>  _qemu_clock_get_ns in qemu-timer.o
>>  "_use_rt_clock", referenced from:
>>  _bdrv_acct_start in block.o
>>  _bdrv_acct_done in block.o
>>  _qemu_clock_get_ns in qemu-timer.o
> 
> If you configure with --disable-tools does it manage to build,
> or does it just go on to fail to link the main QEMU binary
> with the same error? (We've had some issues in the past I think
> where configure put libraries on the main binary link line but
> not on the tools link lines, so maybe worth a try...)
> 
> thanks
> -- PMM
> 

It still fails to build:

Build commands: ./configure --disable-tools --target-list=i386-softmmu
&& make -j 4

QEMU at commit: 306ec6c3cece7004429c79c1ac93d49919f1f1cc

  LINK  i386-softmmu/qemu-system-i386
Undefined symbols for architecture x86_64:
  "_use_rt_clock", referenced from:
  _bdrv_acct_start in block.o
  _bdrv_acct_done in block.o
  _qemu_clock_get_ns in qemu-timer.o
  _cpu_get_clock in cpus.o
  _cpu_enable_ticks in cpus.o
  _cpu_disable_ticks in cpus.o
  _icount_warp_rt in cpus.o
  ...
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [qemu-system-i386] Error 1
make: *** [subdir-i386-softmmu] Error 2

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1737194

Title:
  Windows NT 4.0 fails to boot from qcow2 installation

Status in QEMU:
  New

Bug description:
  Windows NT 4.0 will not boot from an installation more than once if
  installed in a qcow2 image file. A quick fix to this problem is to use
  the qcow format instead.

  Steps to reproduce this issue:

  Create the image file:
  qemu-img create -f qcow2 winnt4.qcow2 1G

  Boot from a Windows NT 4.0 Workstation CD:
  qemu-system-i386 -hda winnt4.qcow2 -cdrom /dev/cdrom -boot d -m 128 -cpu 
pentium -vga cirrus

  During the installation process you have the choise between FAT and
  NTFS. You can pick anyone.

  After finishing the installation the guest will reboot to install
  additional items. Once this is done the guest will be bootable. Eject
  any CD media from QEMU and reboot. You will then see Windows NT 4.0
  booting up to the desktop. Go to "Start->Shut down" to shut down. Then
  when Windows is ready quit QEMU.

  Now try to boot using this command:
  qemu-system-i386 -hda winnt4.qcow2 -boot c -m 128 -cpu pentium -vga cirrus 
   
  The BIOS screen will display an error message:

  For NTFS: 
  Booting from Hard Disk...
  A disk read error occurred.
  Insert a system diskette and restart
  the system.

  For FAT:
  No bootable device.

  Additional information:
  qemu-system-i386 version: 2.10.1
  qemu-img version: 2.10.92 (v2.11.0-rc4-dirty)

  If you don't have a Windows NT 4.0 Workstation installation CD, you may 
download one from here:
  https://winworldpc.com/product/windows-nt-40/40

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1737194/+subscriptions



Re: [Qemu-devel] [Bug 1737194] Re: Windows NT 4.0 fails to boot from qcow2 installation

2018-01-25 Thread John Arbuckle
> # WinNT 4 Terminal Server
> 
> Most of the time, NTLDR will fire up normally. But every so often...
> 
>   SeaBIOS (version 
> rel-1.7.3-117-g31b8b4e-20131206_080705-nilsson.home.kraxel.org)
> 
>   Booting from Hard Disk...
>   A disk read error occurred.
>   Insert a system diskette and restart
>   the system.
> 
> (NB. You're seeing the old SeaBIOS version included with e689f7c, which was 
> the first buggy commit.)
> 
> If NT gets past this point without erroring out (ie, it makes it to the boot 
> menu), the rest of the system is 100% fine and there are no other disk I/O 
> issues whatsoever. For example, on QEMU 2.9.0 I was able to enable disk 
> compression, answer "Yes" to "Compress entire disk now?" and have the process 
> fully complete. No hitches.
> 

I tried adding -M isapc to my Windows NT 4.0 VM's arguments and I saw
the same error message at first. Then I tried it again by making a few
changes. I played with the network card settings and removed the "-M
isapc" argument to make things work again. Then I went back and added
the "-M isapc" option again and Windows booted. I restarted several
times and didn't see the error message. I am using qemu-system-i386
version 2.10.1. Just to see if I could see any of the disk errors you
saw I ran in the command prompt "chkdsk c:" a couple of times. It came
back with no errors every time.

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1737194

Title:
  Windows NT 4.0 fails to boot from qcow2 installation

Status in QEMU:
  New

Bug description:
  Windows NT 4.0 will not boot from an installation more than once if
  installed in a qcow2 image file. A quick fix to this problem is to use
  the qcow format instead.

  Steps to reproduce this issue:

  Create the image file:
  qemu-img create -f qcow2 winnt4.qcow2 1G

  Boot from a Windows NT 4.0 Workstation CD:
  qemu-system-i386 -hda winnt4.qcow2 -cdrom /dev/cdrom -boot d -m 128 -cpu 
pentium -vga cirrus

  During the installation process you have the choise between FAT and
  NTFS. You can pick anyone.

  After finishing the installation the guest will reboot to install
  additional items. Once this is done the guest will be bootable. Eject
  any CD media from QEMU and reboot. You will then see Windows NT 4.0
  booting up to the desktop. Go to "Start->Shut down" to shut down. Then
  when Windows is ready quit QEMU.

  Now try to boot using this command:
  qemu-system-i386 -hda winnt4.qcow2 -boot c -m 128 -cpu pentium -vga cirrus 
   
  The BIOS screen will display an error message:

  For NTFS: 
  Booting from Hard Disk...
  A disk read error occurred.
  Insert a system diskette and restart
  the system.

  For FAT:
  No bootable device.

  Additional information:
  qemu-system-i386 version: 2.10.1
  qemu-img version: 2.10.92 (v2.11.0-rc4-dirty)

  If you don't have a Windows NT 4.0 Workstation installation CD, you may 
download one from here:
  https://winworldpc.com/product/windows-nt-40/40

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1737194/+subscriptions



Re: [Qemu-devel] [Bug 1737194] Re: Windows NT 4.0 fails to boot from qcow2 installation

2018-01-25 Thread John Arbuckle
> On Jan 25, 2018, at 2:53 AM, i336_ <asm...@gmail.com> wrote:
> 
> Hi,
> 
> I've been experiencing various disk I/O issues with Windows NT too, as
> well as with Windows 3.1. I think `-M isapc` may be to blame somehow.
> 
> I've documented my experiences over at
> https://bugs.launchpad.net/qemu/+bug/1745312.
> 
> That report contains information on how to lift out and build the
> before-and-after QEMU commits that I think relate to this being broken.
> John Arbuckle, perhaps you could run through that and see if you
> continue to have issues.
> 
> I was initially going to post that report as a comment in this thread,
> until I realized I was having I/O issues on multiple operating systems.
> 
> -- 
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1737194
> 
> Title:
>  Windows NT 4.0 fails to boot from qcow2 installation
> 
> Status in QEMU:
>  New
> 
> Bug description:
>  Windows NT 4.0 will not boot from an installation more than once if
>  installed in a qcow2 image file. A quick fix to this problem is to use
>  the qcow format instead.
> 
>  Steps to reproduce this issue:
> 
>  Create the image file:
>  qemu-img create -f qcow2 winnt4.qcow2 1G
> 
>  Boot from a Windows NT 4.0 Workstation CD:
>  qemu-system-i386 -hda winnt4.qcow2 -cdrom /dev/cdrom -boot d -m 128 -cpu 
> pentium -vga cirrus
> 
>  During the installation process you have the choise between FAT and
>  NTFS. You can pick anyone.
> 
>  After finishing the installation the guest will reboot to install
>  additional items. Once this is done the guest will be bootable. Eject
>  any CD media from QEMU and reboot. You will then see Windows NT 4.0
>  booting up to the desktop. Go to "Start->Shut down" to shut down. Then
>  when Windows is ready quit QEMU.
> 
>  Now try to boot using this command:
>  qemu-system-i386 -hda winnt4.qcow2 -boot c -m 128 -cpu pentium -vga cirrus 
> 
>  The BIOS screen will display an error message:
> 
>  For NTFS: 
>  Booting from Hard Disk...
>  A disk read error occurred.
>  Insert a system diskette and restart
>  the system.
> 
>  For FAT:
>  No bootable device.
> 
>  Additional information:
>  qemu-system-i386 version: 2.10.1
>  qemu-img version: 2.10.92 (v2.11.0-rc4-dirty)
> 
>  If you don't have a Windows NT 4.0 Workstation installation CD, you may 
> download one from here:
>  https://winworldpc.com/product/windows-nt-40/40
> 
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/qemu/+bug/1737194/+subscriptions

I did try to build at commits 306ec6c3cece7004429c79c1ac93d49919f1f1cc
and e689f7c668cbd9d08f330e17c3dd3a059c9553d3. Both failed to build on my
Mac OS X system. Here is the error message I usually saw:

  LINK  qemu-io
Undefined symbols for architecture x86_64:
  "_use_rt_clock", referenced from:
  _bdrv_acct_start in block.o
  _bdrv_acct_done in block.o
Undefined symbols for architecture x86_64:
  _qemu_clock_get_ns in qemu-timer.o
  "_use_rt_clock", referenced from:
  _bdrv_acct_start in block.o
  _bdrv_acct_done in block.o
  _qemu_clock_get_ns in qemu-timer.o

In your report you mention using the raw disk image format and VHD(x). I
have had great success with the qcow image format. Could you try it and
let us know if it fixes things for you?

To create a qcow image file:
 qemu-img create -f qcow .qcow 1G

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1737194

Title:
  Windows NT 4.0 fails to boot from qcow2 installation

Status in QEMU:
  New

Bug description:
  Windows NT 4.0 will not boot from an installation more than once if
  installed in a qcow2 image file. A quick fix to this problem is to use
  the qcow format instead.

  Steps to reproduce this issue:

  Create the image file:
  qemu-img create -f qcow2 winnt4.qcow2 1G

  Boot from a Windows NT 4.0 Workstation CD:
  qemu-system-i386 -hda winnt4.qcow2 -cdrom /dev/cdrom -boot d -m 128 -cpu 
pentium -vga cirrus

  During the installation process you have the choise between FAT and
  NTFS. You can pick anyone.

  After finishing the installation the guest will reboot to install
  additional items. Once this is done the guest will be bootable. Eject
  any CD media from QEMU and reboot. You will then see Windows NT 4.0
  booting up to the desktop. Go to "Start->Shut down" to shut down. Then
  when Windows is ready quit QEMU.

  Now try to boot using this command:
  qemu-system-i386 -hda winnt4.qcow2 -boot c -m 128 -cpu pentium -vga cirrus 
   
  The BIOS screen will display an error message:

  For NTFS: 
  Booting from Hard Disk...
  A disk read error o

[Qemu-devel] [PATCH v2] cocoa.m: Fix scroll wheel support

2018-01-08 Thread John Arbuckle
When using a mouse's scroll wheel in a guest with
the cocoa front-end, the mouse pointer moves up
and down instead of scrolling the window. This
patch fixes this problem.

Signed-off-by: John Arbuckle <programmingk...@gmail.com>
---
 ui/cocoa.m | 27 +++
 1 file changed, 19 insertions(+), 8 deletions(-)

diff --git a/ui/cocoa.m b/ui/cocoa.m
index 330ccebf90..6be9848391 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -786,11 +786,24 @@ - (void) handleEvent:(NSEvent *)event
 mouse_event = true;
 break;
 case NSEventTypeScrollWheel:
-if (isMouseGrabbed) {
-buttons |= ([event deltaY] < 0) ?
-MOUSE_EVENT_WHEELUP : MOUSE_EVENT_WHEELDN;
-}
-mouse_event = true;
+/*
+ * Send wheel events to the guest regardless of window focus.
+ * This is in-line with standard Mac OS X UI behaviour.
+ */
+
+/* Determine if this is a scroll up or scroll down event */
+buttons = ([event scrollingDeltaY] > 0) ?
+INPUT_BUTTON_WHEEL_UP : INPUT_BUTTON_WHEEL_DOWN;
+qemu_input_queue_btn(dcl->con, buttons, true);
+qemu_input_event_sync();
+qemu_input_queue_btn(dcl->con, buttons, false);
+qemu_input_event_sync();
+
+/*
+ * Since deltaY also reports scroll wheel events we prevent mouse
+ * movement code from executing.
+ */
+mouse_event = false;
 break;
 default:
 [NSApp sendEvent:event];
@@ -809,9 +822,7 @@ - (void) handleEvent:(NSEvent *)event
 static uint32_t bmap[INPUT_BUTTON__MAX] = {
 [INPUT_BUTTON_LEFT]   = MOUSE_EVENT_LBUTTON,
 [INPUT_BUTTON_MIDDLE] = MOUSE_EVENT_MBUTTON,
-[INPUT_BUTTON_RIGHT]  = MOUSE_EVENT_RBUTTON,
-[INPUT_BUTTON_WHEEL_UP]   = MOUSE_EVENT_WHEELUP,
-[INPUT_BUTTON_WHEEL_DOWN] = MOUSE_EVENT_WHEELDN,
+[INPUT_BUTTON_RIGHT]  = MOUSE_EVENT_RBUTTON
 };
 qemu_input_update_buttons(dcl->con, bmap, last_buttons, buttons);
 last_buttons = buttons;
-- 
2.14.3 (Apple Git-98)




[Qemu-devel] [PATCH v2] Update dtc to fix compilation problem on Mac OS 10.6

2018-01-04 Thread John Arbuckle
Currently QEMU does not build on Mac OS 10.6
because of a missing patch in the dtc
subproject. Updating dtc to make the patch
available fixes this problem.

Signed-off-by: John Arbuckle <programmingk...@gmail.com>
---
v2 changes:
Updated the commit to point to version 1.4.6.

 dtc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/dtc b/dtc
index 558cd81bdd..e54388015a 16
--- a/dtc
+++ b/dtc
@@ -1 +1 @@
-Subproject commit 558cd81bdd432769b59bff01240c44f82cfb1a9d
+Subproject commit e54388015af1fb4bf04d0bca99caba1074d9cc42
-- 
2.14.3 (Apple Git-98)




[Qemu-devel] [PATCH] cocoa.m: Fix scroll wheel support

2017-12-30 Thread John Arbuckle
When using a mouse's scroll wheel in a guest with the cocoa front-end, the 
mouse pointer moves up and down instead of scrolling the window. This patch 
fixes this problem.

Signed-off-by: John Arbuckle <programmingk...@gmail.com>
---
 ui/cocoa.m | 17 -
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/ui/cocoa.m b/ui/cocoa.m
index 330ccebf90..d2e5f80b74 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -786,11 +786,18 @@ - (void) handleEvent:(NSEvent *)event
 mouse_event = true;
 break;
 case NSEventTypeScrollWheel:
-if (isMouseGrabbed) {
-buttons |= ([event deltaY] < 0) ?
-MOUSE_EVENT_WHEELUP : MOUSE_EVENT_WHEELDN;
-}
-mouse_event = true;
+/* Determine if this is a scroll up or scroll down event */
+buttons = ([event scrollingDeltaY] > 0) ?
+INPUT_BUTTON_WHEEL_UP : INPUT_BUTTON_WHEEL_DOWN;
+qemu_input_queue_btn(dcl->con, buttons, true);
+qemu_input_event_sync();
+qemu_input_queue_btn(dcl->con, buttons, false);
+qemu_input_event_sync();
+/*
+ * Since deltaY also reports scroll wheel events we prevent mouse
+ * movement code from executing.
+ */
+mouse_event = false;
 break;
 default:
 [NSApp sendEvent:event];
-- 
2.14.3 (Apple Git-98)




[Qemu-devel] [PATCH] Update dtc to fix compilation problem on Mac OS 10.6

2017-12-27 Thread John Arbuckle
Currently QEMU does not build on Mac OS 10.6
because of a missing patch in the dtc
subproject. Updating dtc to make the patch
available fixes this problem.

Signed-off-by: John Arbuckle <programmingk...@gmail.com>
---
 dtc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/dtc b/dtc
index 558cd81bdd..e671852042 16
--- a/dtc
+++ b/dtc
@@ -1 +1 @@
-Subproject commit 558cd81bdd432769b59bff01240c44f82cfb1a9d
+Subproject commit e671852042a77b15ec72ca908291c7d647e4fb01
-- 
2.14.3 (Apple Git-98)




[Qemu-devel] [PATCH v4] Add ability for user to specify mouse ungrab key

2017-12-26 Thread John Arbuckle
Currently the ungrab keys for the Cocoa and GTK interface are Control-Alt-g.
This combination may not be very fun for the user to have to enter, so we
now enable the user to specify their own key(s) as the ungrab key(s). The
list of keys that can be used is found in the file qapi/ui.json under QKeyCode.
The max number of keys that can be used is three. The original ungrab keys
still remain usable because there is a real risk of the user forgetting 
the keys he or she specified as the ungrab keys. They remain as a plan B
if plan A is forgotten.

Syntax: -ungrab 

Example usage:  -ungrab home
-ungrab shift-ctrl
-ungrab ctrl-x
-ungrab pgup-pgdn
-ungrab kp_5-kp_6
-ungrab kp_4-kp_5-kp_6

Signed-off-by: John Arbuckle <programmingk...@gmail.com>
---
v4 changes:
- Removed initialization code for key_value_array.
- Added void keyword to console_ungrab_key_sequence(),
  and console_ungrab_key_string() functions.

v3 changes:
- Added the ability for any "sendkey supported" key to be used.
- Added ability for one to three key sequences to be used.

v2 changes:
- Removed the "int i" code from the for loops. 

 include/ui/console.h |  6 ++
 qemu-options.hx  |  2 ++
 ui/cocoa.m   | 48 +++--
 ui/console.c | 60 
 vl.c |  3 +++
 5 files changed, 117 insertions(+), 2 deletions(-)

diff --git a/include/ui/console.h b/include/ui/console.h
index 580dfc57ee..37dc150268 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -534,4 +534,10 @@ static inline void early_gtk_display_init(int opengl)
 /* egl-headless.c */
 void egl_headless_init(void);
 
+/* console.c */
+void set_ungrab_seq(const char *new_seq);
+int *console_ungrab_key_sequence(void);
+const char *console_ungrab_key_string(void);
+int console_ungrab_sequence_length(void);
+
 #endif
diff --git a/qemu-options.hx b/qemu-options.hx
index 94647e21e3..51666e6f74 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -4264,6 +4264,8 @@ contents of @code{iv.b64} to the second secret
 
 ETEXI
 
+DEF("ungrab", HAS_ARG, QEMU_OPTION_ungrab, \
+"-ungrab ", QEMU_ARCH_ALL)
 
 HXCOMM This is the last statement. Insert new options before this line!
 STEXI
diff --git a/ui/cocoa.m b/ui/cocoa.m
index 330ccebf90..412a5fc02d 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -303,6 +303,7 @@ - (float) cdx;
 - (float) cdy;
 - (QEMUScreen) gscreen;
 - (void) raiseAllKeys;
+- (bool) user_ungrab_seq;
 @end
 
 QemuCocoaView *cocoaView;
@@ -674,9 +675,24 @@ - (void) handleEvent:(NSEvent *)event
 }
 }
 
+/*
+ * This code has to be here because the user might use a modifier
+ * key like shift as an ungrab key.
+ */
+if ([self user_ungrab_seq] == true) {
+[self ungrabMouse];
+return;
+}
 break;
 case NSEventTypeKeyDown:
 keycode = cocoa_keycode_to_qemu([event keyCode]);
+[self toggleModifier: keycode];
+
+// If the user is issuing the custom ungrab key sequence
+if ([self user_ungrab_seq] == true) {
+[self ungrabMouse];
+return;
+}
 
 // forward command key combos to the host UI unless the mouse is 
grabbed
 if (!isMouseGrabbed && ([event modifierFlags] & 
NSEventModifierFlagCommand)) {
@@ -714,6 +730,7 @@ - (void) handleEvent:(NSEvent *)event
 break;
 case NSEventTypeKeyUp:
 keycode = cocoa_keycode_to_qemu([event keyCode]);
+[self toggleModifier: keycode];
 
 // don't pass the guest a spurious key-up if we treated this
 // command-key combo as a host UI action
@@ -842,10 +859,18 @@ - (void) grabMouse
 COCOA_DEBUG("QemuCocoaView: grabMouse\n");
 
 if (!isFullscreen) {
+NSString * message_string;
+if (console_ungrab_sequence_length() == 0) {
+message_string = [NSString stringWithFormat: @"- (Press ctrl + alt 
+ g to release Mouse"];
+} else {
+message_string = [NSString stringWithFormat: @"- (Press ctrl + alt 
+ g or %s to release Mouse", console_ungrab_key_string()];
+}
+
+
 if (qemu_name)
-[normalWindow setTitle:[NSString stringWithFormat:@"QEMU %s - 
(Press ctrl + alt + g to release Mouse)", qemu_name]];
+[normalWindow setTitle:[NSString stringWithFormat: @"QEMU %s %@", 
qemu_name, message_string]];
 else
-[normalWindow setTitle:@"QEMU - (Press ctrl + alt + g to release 
Mouse)"];
+[normalWindow setTitle:[NSString stringWithFormat: @"QEMU %@", 
message_string]];
 }
 [self hideCursor];
 if (!

[Qemu-devel] [PATCH v3] Add ability for user to specify mouse ungrab key

2017-12-26 Thread John Arbuckle
Currently the ungrab keys for the Cocoa and GTK interface are Control-Alt-g.
This combination may not be very fun for the user to have to enter, so we
now enable the user to specify their own key(s) as the ungrab key(s). The
list of keys that can be used is found in the file qapi/ui.json under QKeyCode.
The max number of keys that can be used is three. The original ungrab keys
still remain usable because there is a real risk of the user forgetting 
the keys he or she specified as the ungrab keys. They remain as a plan B
if plan A is forgotten.

Syntax: -ungrab 

Example usage:  -ungrab home
-ungrab shift-ctrl
-ungrab ctrl-x
-ungrab pgup-pgdn
-ungrab kp_5-kp_6
-ungrab kp_4-kp_5-kp_6

Signed-off-by: John Arbuckle <programmingk...@gmail.com>
---
v3 changes:
- Added the ability for any "sendkey supported" key to be used.
- Added ability for one to three key sequences to be used.

v2 changes:
- Removed the "int i" code from the for loops. 

 include/ui/console.h |  6 ++
 qemu-options.hx  |  2 ++
 ui/cocoa.m   | 48 +++--
 ui/console.c | 61 
 vl.c |  3 +++
 5 files changed, 118 insertions(+), 2 deletions(-)

diff --git a/include/ui/console.h b/include/ui/console.h
index 580dfc57ee..37dc150268 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -534,4 +534,10 @@ static inline void early_gtk_display_init(int opengl)
 /* egl-headless.c */
 void egl_headless_init(void);
 
+/* console.c */
+void set_ungrab_seq(const char *new_seq);
+int *console_ungrab_key_sequence(void);
+const char *console_ungrab_key_string(void);
+int console_ungrab_sequence_length(void);
+
 #endif
diff --git a/qemu-options.hx b/qemu-options.hx
index 94647e21e3..51666e6f74 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -4264,6 +4264,8 @@ contents of @code{iv.b64} to the second secret
 
 ETEXI
 
+DEF("ungrab", HAS_ARG, QEMU_OPTION_ungrab, \
+"-ungrab ", QEMU_ARCH_ALL)
 
 HXCOMM This is the last statement. Insert new options before this line!
 STEXI
diff --git a/ui/cocoa.m b/ui/cocoa.m
index 330ccebf90..412a5fc02d 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -303,6 +303,7 @@ - (float) cdx;
 - (float) cdy;
 - (QEMUScreen) gscreen;
 - (void) raiseAllKeys;
+- (bool) user_ungrab_seq;
 @end
 
 QemuCocoaView *cocoaView;
@@ -674,9 +675,24 @@ - (void) handleEvent:(NSEvent *)event
 }
 }
 
+/*
+ * This code has to be here because the user might use a modifier
+ * key like shift as an ungrab key.
+ */
+if ([self user_ungrab_seq] == true) {
+[self ungrabMouse];
+return;
+}
 break;
 case NSEventTypeKeyDown:
 keycode = cocoa_keycode_to_qemu([event keyCode]);
+[self toggleModifier: keycode];
+
+// If the user is issuing the custom ungrab key sequence
+if ([self user_ungrab_seq] == true) {
+[self ungrabMouse];
+return;
+}
 
 // forward command key combos to the host UI unless the mouse is 
grabbed
 if (!isMouseGrabbed && ([event modifierFlags] & 
NSEventModifierFlagCommand)) {
@@ -714,6 +730,7 @@ - (void) handleEvent:(NSEvent *)event
 break;
 case NSEventTypeKeyUp:
 keycode = cocoa_keycode_to_qemu([event keyCode]);
+[self toggleModifier: keycode];
 
 // don't pass the guest a spurious key-up if we treated this
 // command-key combo as a host UI action
@@ -842,10 +859,18 @@ - (void) grabMouse
 COCOA_DEBUG("QemuCocoaView: grabMouse\n");
 
 if (!isFullscreen) {
+NSString * message_string;
+if (console_ungrab_sequence_length() == 0) {
+message_string = [NSString stringWithFormat: @"- (Press ctrl + alt 
+ g to release Mouse"];
+} else {
+message_string = [NSString stringWithFormat: @"- (Press ctrl + alt 
+ g or %s to release Mouse", console_ungrab_key_string()];
+}
+
+
 if (qemu_name)
-[normalWindow setTitle:[NSString stringWithFormat:@"QEMU %s - 
(Press ctrl + alt + g to release Mouse)", qemu_name]];
+[normalWindow setTitle:[NSString stringWithFormat: @"QEMU %s %@", 
qemu_name, message_string]];
 else
-[normalWindow setTitle:@"QEMU - (Press ctrl + alt + g to release 
Mouse)"];
+[normalWindow setTitle:[NSString stringWithFormat: @"QEMU %@", 
message_string]];
 }
 [self hideCursor];
 if (!isAbsoluteEnabled) {
@@ -898,6 +923,25 @@ - (void) raiseAllKeys
}
}
 }
+
+/* Determines if the user specified ungrab sequence is 

[Qemu-devel] [PATCH v2] Add ability for user to specify mouse ungrab key

2017-12-14 Thread John Arbuckle
Currently the ungrab keys for the Cocoa and GTK interface are Control-Alt-g.
This combination may not be very fun for the user to have to enter, so we
now enable the user to specify their own key as the ungrab key. Since the 
function keys are the keys that don't tend to be used that often and are
usually available, they will be the ones the user can pick to be the ungrab
key.

Signed-off-by: John Arbuckle <programmingk...@gmail.com>
---
v2 changes:
- Removed the "int i" code from the for loops. 

 qemu-options.hx |  2 ++
 ui/cocoa.m  | 20 ++--
 vl.c| 73 -
 3 files changed, 92 insertions(+), 3 deletions(-)

diff --git a/qemu-options.hx b/qemu-options.hx
index f11c4ac960..0a727ea50a 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -4472,6 +4472,8 @@ contents of @code{iv.b64} to the second secret
 
 ETEXI
 
+DEF("ungrab", HAS_ARG, QEMU_OPTION_ungrab, \
+"-ungrab ", QEMU_ARCH_ALL)
 
 HXCOMM This is the last statement. Insert new options before this line!
 STEXI
diff --git a/ui/cocoa.m b/ui/cocoa.m
index 330ccebf90..8dc603adf0 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -106,6 +106,9 @@
 NSTextField *pauseLabel;
 NSArray * supportedImageFileTypes;
 
+int get_ungrab_key_value(void);
+const char * get_ungrab_key_name(void);
+
 // Mac to QKeyCode conversion
 const int mac_to_qkeycode_map[] = {
 [kVK_ANSI_A] = Q_KEY_CODE_A,
@@ -678,6 +681,12 @@ - (void) handleEvent:(NSEvent *)event
 case NSEventTypeKeyDown:
 keycode = cocoa_keycode_to_qemu([event keyCode]);
 
+// if the user wants to release the mouse grab
+if (keycode == get_ungrab_key_value()) {
+[self ungrabMouse];
+return;
+}
+
 // forward command key combos to the host UI unless the mouse is 
grabbed
 if (!isMouseGrabbed && ([event modifierFlags] & 
NSEventModifierFlagCommand)) {
 [NSApp sendEvent:event];
@@ -842,10 +851,17 @@ - (void) grabMouse
 COCOA_DEBUG("QemuCocoaView: grabMouse\n");
 
 if (!isFullscreen) {
+NSString * message_string;
+if (get_ungrab_key_value() < 0) {
+message_string = [NSString stringWithFormat: @"- (Press ctrl + alt 
+ g to release Mouse"];
+} else {
+message_string = [NSString stringWithFormat: @"- (Press ctrl + alt 
+ g or %s to release Mouse", get_ungrab_key_name()];
+}
+
 if (qemu_name)
-[normalWindow setTitle:[NSString stringWithFormat:@"QEMU %s - 
(Press ctrl + alt + g to release Mouse)", qemu_name]];
+[normalWindow setTitle:[NSString stringWithFormat: @"QEMU %s %@", 
qemu_name, message_string]];
 else
-[normalWindow setTitle:@"QEMU - (Press ctrl + alt + g to release 
Mouse)"];
+[normalWindow setTitle:[NSString stringWithFormat: @"QEMU %@", 
message_string]];
 }
 [self hideCursor];
 if (!isAbsoluteEnabled) {
diff --git a/vl.c b/vl.c
index 1ad1c04637..c2d848fabc 100644
--- a/vl.c
+++ b/vl.c
@@ -185,7 +185,8 @@ bool boot_strict;
 uint8_t *boot_splash_filedata;
 size_t boot_splash_filedata_size;
 uint8_t qemu_extra_params_fw[2];
-
+int ungrab_key_value = -1;
+char *ungrab_key_name;
 int icount_align_option;
 
 /* The bytes in qemu_uuid are in the order specified by RFC4122, _not_ in the
@@ -3088,6 +3089,73 @@ static void register_global_properties(MachineState *ms)
 user_register_global_props();
 }
 
+/* Sets the mouse ungrab key to what the user wants */
+static void set_ungrab_key(const char *new_key)
+{
+const char *keys[] = {
+[0 ... 0xff]= "",
+[Q_KEY_CODE_F1] = "f1",
+[Q_KEY_CODE_F2] = "f2",
+[Q_KEY_CODE_F3] = "f3",
+[Q_KEY_CODE_F4] = "f4",
+[Q_KEY_CODE_F5] = "f5",
+[Q_KEY_CODE_F6] = "f6",
+[Q_KEY_CODE_F7] = "f7",
+[Q_KEY_CODE_F8] = "f8",
+[Q_KEY_CODE_F9] = "f9",
+[Q_KEY_CODE_F10] = "f10",
+[Q_KEY_CODE_F11] = "f11",
+[Q_KEY_CODE_F12] = "f12",
+[Q_KEY_CODE_PRINT] = "f13",
+[Q_KEY_CODE_SCROLL_LOCK] = "f14",
+[Q_KEY_CODE_PAUSE] = "f15",
+};
+
+int key_value = -1;
+int i;
+
+/* see if the user's key is recognized */
+for (i = 0; i < ARRAY_SIZE(keys); i++) {
+if (strcmp(keys[i], new_key) == 0) {
+key_value = i;
+break;
+}
+}
+
+/* if the user's key isn't recognized print the usable keys */
+if (key_value == -1) {
+printf("Unrecognized key: %s\n", new_key);
+printf("Usable ungrab keys: ");
+for (i = 0; i < ARRAY_SIZE(keys); i++) {
+

[Qemu-devel] [PATCH] Add ability for user to specify mouse ungrab key

2017-12-10 Thread John Arbuckle
Currently the ungrab keys for the Cocoa and GTK interface are Control-Alt-g.
This combination may not be very fun for the user to have to enter, so we
now enable the user to specify their own key as the ungrab key. Since the 
function keys are the keys that don't tend to be used that often and are
usually available, they will be the ones the user can pick to be the ungrab
key.

Signed-off-by: John Arbuckle <programmingk...@gmail.com>
---
 qemu-options.hx |  2 ++
 ui/cocoa.m  | 20 --
 vl.c| 85 -
 3 files changed, 104 insertions(+), 3 deletions(-)

diff --git a/qemu-options.hx b/qemu-options.hx
index f11c4ac960..0a727ea50a 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -4472,6 +4472,8 @@ contents of @code{iv.b64} to the second secret
 
 ETEXI
 
+DEF("ungrab", HAS_ARG, QEMU_OPTION_ungrab, \
+"-ungrab ", QEMU_ARCH_ALL)
 
 HXCOMM This is the last statement. Insert new options before this line!
 STEXI
diff --git a/ui/cocoa.m b/ui/cocoa.m
index 330ccebf90..8dc603adf0 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -106,6 +106,9 @@
 NSTextField *pauseLabel;
 NSArray * supportedImageFileTypes;
 
+int get_ungrab_key_value(void);
+const char * get_ungrab_key_name(void);
+
 // Mac to QKeyCode conversion
 const int mac_to_qkeycode_map[] = {
 [kVK_ANSI_A] = Q_KEY_CODE_A,
@@ -678,6 +681,12 @@ - (void) handleEvent:(NSEvent *)event
 case NSEventTypeKeyDown:
 keycode = cocoa_keycode_to_qemu([event keyCode]);
 
+// if the user wants to release the mouse grab
+if (keycode == get_ungrab_key_value()) {
+[self ungrabMouse];
+return;
+}
+
 // forward command key combos to the host UI unless the mouse is 
grabbed
 if (!isMouseGrabbed && ([event modifierFlags] & 
NSEventModifierFlagCommand)) {
 [NSApp sendEvent:event];
@@ -842,10 +851,17 @@ - (void) grabMouse
 COCOA_DEBUG("QemuCocoaView: grabMouse\n");
 
 if (!isFullscreen) {
+NSString * message_string;
+if (get_ungrab_key_value() < 0) {
+message_string = [NSString stringWithFormat: @"- (Press ctrl + alt 
+ g to release Mouse"];
+} else {
+message_string = [NSString stringWithFormat: @"- (Press ctrl + alt 
+ g or %s to release Mouse", get_ungrab_key_name()];
+}
+
 if (qemu_name)
-[normalWindow setTitle:[NSString stringWithFormat:@"QEMU %s - 
(Press ctrl + alt + g to release Mouse)", qemu_name]];
+[normalWindow setTitle:[NSString stringWithFormat: @"QEMU %s %@", 
qemu_name, message_string]];
 else
-[normalWindow setTitle:@"QEMU - (Press ctrl + alt + g to release 
Mouse)"];
+[normalWindow setTitle:[NSString stringWithFormat: @"QEMU %@", 
message_string]];
 }
 [self hideCursor];
 if (!isAbsoluteEnabled) {
diff --git a/vl.c b/vl.c
index 1ad1c04637..58a606e8a3 100644
--- a/vl.c
+++ b/vl.c
@@ -185,7 +185,8 @@ bool boot_strict;
 uint8_t *boot_splash_filedata;
 size_t boot_splash_filedata_size;
 uint8_t qemu_extra_params_fw[2];
-
+int ungrab_key_value = -1;
+char *ungrab_key_name;
 int icount_align_option;
 
 /* The bytes in qemu_uuid are in the order specified by RFC4122, _not_ in the
@@ -3088,6 +3089,85 @@ static void register_global_properties(MachineState *ms)
 user_register_global_props();
 }
 
+/* Sets the mouse ungrab key to what the user wants */
+static void set_ungrab_key(const char *new_key)
+{
+const char *keys[] = {
+[0 ... 0xff]= "",
+[Q_KEY_CODE_F1] = "f1",
+[Q_KEY_CODE_F2] = "f2",
+[Q_KEY_CODE_F3] = "f3",
+[Q_KEY_CODE_F4] = "f4",
+[Q_KEY_CODE_F5] = "f5",
+[Q_KEY_CODE_F6] = "f6",
+[Q_KEY_CODE_F7] = "f7",
+[Q_KEY_CODE_F8] = "f8",
+[Q_KEY_CODE_F9] = "f9",
+[Q_KEY_CODE_F10] = "f10",
+[Q_KEY_CODE_F11] = "f11",
+[Q_KEY_CODE_F12] = "f12",
+[Q_KEY_CODE_PRINT] = "f13",
+[Q_KEY_CODE_SCROLL_LOCK] = "f14",
+[Q_KEY_CODE_PAUSE] = "f15",
+
+#if 0  /* remove this once these function keys are defined */
+[Q_KEY_CODE_F16] = "f16",
+[Q_KEY_CODE_F17] = "f17",
+[Q_KEY_CODE_F18] = "f18",
+[Q_KEY_CODE_F19] = "f19",
+[Q_KEY_CODE_F20] = "f20",
+[Q_KEY_CODE_F21] = "f21",
+[Q_KEY_CODE_F22] = "f22",
+[Q_KEY_CODE_F23] = "f23",
+[Q_KEY_CODE_F24] = "f24",
+[Q_KEY_CODE_FUNCTION] = "fn",
+#endif
+};
+
+int key_value = -1;
+
+/* see if the user

Re: [Qemu-devel] [Bug 1737194] Re: Windows NT 4.0 fails to boot from qcow2 installation

2017-12-08 Thread John Arbuckle
> On Dec 8, 2017, at 1:41 PM, John Snow <1737...@bugs.launchpad.net> wrote:
> 
> If you do two identical installs with qcow2 and raw, do you see any
> differences with qemu-img compare afterwards that might indicate what
> could possibly have gone wrong?

I think what you want is for me to compare a broken qcow2 file with a
working qcow file. I'm not sure how to do that but if you sent me
directions I can send you the results.

I did try using the broken qcow2 file in a Windows XP VM. When I try to
open the "Program Files" folder I see this error message: "D:\Program
Files is not accessible. The file or directory is corrupted and
unreadable". The WINNT folder does open.

I tried checking the disk with Windows XP's disk repair utility. It
failed to complete and displayed this error message: "Windows was unable
to complete the disk check".

> 
> -- 
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1737194
> 
> Title:
>  Windows NT 4.0 fails to boot from qcow2 installation
> 
> Status in QEMU:
>  New
> 
> Bug description:
>  Windows NT 4.0 will not boot from an installation more than once if
>  installed in a qcow2 image file. A quick fix to this problem is to use
>  the qcow format instead.
> 
>  Steps to reproduce this issue:
> 
>  Create the image file:
>  qemu-img create -f qcow2 winnt4.qcow2 1G
> 
>  Boot from a Windows NT 4.0 Workstation CD:
>  qemu-system-i386 -hda winnt4.qcow2 -cdrom /dev/cdrom -boot d -m 128 -cpu 
> pentium -vga cirrus
> 
>  During the installation process you have the choise between FAT and
>  NTFS. You can pick anyone.
> 
>  After finishing the installation the guest will reboot to install
>  additional items. Once this is done the guest will be bootable. Eject
>  any CD media from QEMU and reboot. You will then see Windows NT 4.0
>  booting up to the desktop. Go to "Start->Shut down" to shut down. Then
>  when Windows is ready quit QEMU.
> 
>  Now try to boot using this command:
>  qemu-system-i386 -hda winnt4.qcow2 -boot c -m 128 -cpu pentium -vga cirrus 
> 
>  The BIOS screen will display an error message:
> 
>  For NTFS: 
>  Booting from Hard Disk...
>  A disk read error occurred.
>  Insert a system diskette and restart
>  the system.
> 
>  For FAT:
>  No bootable device.
> 
>  Additional information:
>  qemu-system-i386 version: 2.10.1
>  qemu-img version: 2.10.92 (v2.11.0-rc4-dirty)
> 
>  If you don't have a Windows NT 4.0 Workstation installation CD, you may 
> download one from here:
>  https://winworldpc.com/product/windows-nt-40/40
> 
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/qemu/+bug/1737194/+subscriptions

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1737194

Title:
  Windows NT 4.0 fails to boot from qcow2 installation

Status in QEMU:
  New

Bug description:
  Windows NT 4.0 will not boot from an installation more than once if
  installed in a qcow2 image file. A quick fix to this problem is to use
  the qcow format instead.

  Steps to reproduce this issue:

  Create the image file:
  qemu-img create -f qcow2 winnt4.qcow2 1G

  Boot from a Windows NT 4.0 Workstation CD:
  qemu-system-i386 -hda winnt4.qcow2 -cdrom /dev/cdrom -boot d -m 128 -cpu 
pentium -vga cirrus

  During the installation process you have the choise between FAT and
  NTFS. You can pick anyone.

  After finishing the installation the guest will reboot to install
  additional items. Once this is done the guest will be bootable. Eject
  any CD media from QEMU and reboot. You will then see Windows NT 4.0
  booting up to the desktop. Go to "Start->Shut down" to shut down. Then
  when Windows is ready quit QEMU.

  Now try to boot using this command:
  qemu-system-i386 -hda winnt4.qcow2 -boot c -m 128 -cpu pentium -vga cirrus 
   
  The BIOS screen will display an error message:

  For NTFS: 
  Booting from Hard Disk...
  A disk read error occurred.
  Insert a system diskette and restart
  the system.

  For FAT:
  No bootable device.

  Additional information:
  qemu-system-i386 version: 2.10.1
  qemu-img version: 2.10.92 (v2.11.0-rc4-dirty)

  If you don't have a Windows NT 4.0 Workstation installation CD, you may 
download one from here:
  https://winworldpc.com/product/windows-nt-40/40

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1737194/+subscriptions



[Qemu-devel] [Bug 1737194] [NEW] Windows NT 4.0 fails to boot from qcow2 installation

2017-12-08 Thread John Arbuckle
Public bug reported:

Windows NT 4.0 will not boot from an installation more than once if
installed in a qcow2 image file. A quick fix to this problem is to use
the qcow format instead.

Steps to reproduce this issue:

Create the image file:
qemu-img create -f qcow2 winnt4.qcow2 1G

Boot from a Windows NT 4.0 Workstation CD:
qemu-system-i386 -hda winnt4.qcow2 -cdrom /dev/cdrom -boot d -m 128 -cpu 
pentium -vga cirrus

During the installation process you have the choise between FAT and
NTFS. You can pick anyone.

After finishing the installation the guest will reboot to install
additional items. Once this is done the guest will be bootable. Eject
any CD media from QEMU and reboot. You will then see Windows NT 4.0
booting up to the desktop. Go to "Start->Shut down" to shut down. Then
when Windows is ready quit QEMU.

Now try to boot using this command:
qemu-system-i386 -hda winnt4.qcow2 -boot c -m 128 -cpu pentium -vga cirrus 
 
The BIOS screen will display an error message:

For NTFS: 
Booting from Hard Disk...
A disk read error occurred.
Insert a system diskette and restart
the system.

For FAT:
No bootable device.

Additional information:
qemu-system-i386 version: 2.10.1
qemu-img version: 2.10.92 (v2.11.0-rc4-dirty)

If you don't have a Windows NT 4.0 Workstation installation CD, you may 
download one from here:
https://winworldpc.com/product/windows-nt-40/40

** Affects: qemu
 Importance: Undecided
 Status: New

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1737194

Title:
  Windows NT 4.0 fails to boot from qcow2 installation

Status in QEMU:
  New

Bug description:
  Windows NT 4.0 will not boot from an installation more than once if
  installed in a qcow2 image file. A quick fix to this problem is to use
  the qcow format instead.

  Steps to reproduce this issue:

  Create the image file:
  qemu-img create -f qcow2 winnt4.qcow2 1G

  Boot from a Windows NT 4.0 Workstation CD:
  qemu-system-i386 -hda winnt4.qcow2 -cdrom /dev/cdrom -boot d -m 128 -cpu 
pentium -vga cirrus

  During the installation process you have the choise between FAT and
  NTFS. You can pick anyone.

  After finishing the installation the guest will reboot to install
  additional items. Once this is done the guest will be bootable. Eject
  any CD media from QEMU and reboot. You will then see Windows NT 4.0
  booting up to the desktop. Go to "Start->Shut down" to shut down. Then
  when Windows is ready quit QEMU.

  Now try to boot using this command:
  qemu-system-i386 -hda winnt4.qcow2 -boot c -m 128 -cpu pentium -vga cirrus 
   
  The BIOS screen will display an error message:

  For NTFS: 
  Booting from Hard Disk...
  A disk read error occurred.
  Insert a system diskette and restart
  the system.

  For FAT:
  No bootable device.

  Additional information:
  qemu-system-i386 version: 2.10.1
  qemu-img version: 2.10.92 (v2.11.0-rc4-dirty)

  If you don't have a Windows NT 4.0 Workstation installation CD, you may 
download one from here:
  https://winworldpc.com/product/windows-nt-40/40

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1737194/+subscriptions



[Qemu-devel] [PATCH v3 1/2] ui/cocoa.m: move ungrab to ctrl-alt-g

2017-11-02 Thread John Arbuckle
Currently the cocoa user interface relys on the user pushing control-alt to 
ungrab the mouse. This is patch changes the key combination to control-alt-g to 
be in line with the GTK user interface. 

Signed-off-by: John Arbuckle <programmingk...@gmail.com>
---
v3 changes
- Code is now keyboard layout aware.

 ui/cocoa.m | 31 ++-
 1 file changed, 18 insertions(+), 13 deletions(-)

diff --git a/ui/cocoa.m b/ui/cocoa.m
index 2794f60b27..e06aa9c65f 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -609,10 +609,6 @@ - (void) handleEvent:(NSEvent *)event
 }
 }
 
-// release Mouse grab when pressing ctrl+alt
-if (([event modifierFlags] & NSEventModifierFlagControl) && 
([event modifierFlags] & NSEventModifierFlagOption)) {
-[self ungrabMouse];
-}
 break;
 case NSEventTypeKeyDown:
 keycode = cocoa_keycode_to_qemu([event keyCode]);
@@ -625,14 +621,23 @@ - (void) handleEvent:(NSEvent *)event
 
 // default
 
-// handle control + alt Key Combos (ctrl+alt is reserved for QEMU)
+// handle control + alt Key Combos (ctrl+alt+[1..9,g] is reserved 
for QEMU)
 if (([event modifierFlags] & NSEventModifierFlagControl) && 
([event modifierFlags] & NSEventModifierFlagOption)) {
-switch (keycode) {
-
-// enable graphic console
-case Q_KEY_CODE_1 ... Q_KEY_CODE_9: // '1' to '9' keys
-console_select(keycode - Q_KEY_CODE_1);
-break;
+NSString *keychar = [event charactersIgnoringModifiers];
+if ([keychar length] == 1) {
+char key = [keychar characterAtIndex:0];
+switch (key) {
+
+// enable graphic console
+case '1' ... '9':
+console_select(key - '0' - 1); /* ascii math */
+return;
+
+// release the mouse grab
+case 'g':
+[self ungrabMouse];
+return;
+}
 }
 
 // handle keys for graphic console
@@ -806,9 +811,9 @@ - (void) grabMouse
 
 if (!isFullscreen) {
 if (qemu_name)
-[normalWindow setTitle:[NSString stringWithFormat:@"QEMU %s - 
(Press ctrl + alt to release Mouse)", qemu_name]];
+[normalWindow setTitle:[NSString stringWithFormat:@"QEMU %s - 
(Press ctrl + alt + g to release Mouse)", qemu_name]];
 else
-[normalWindow setTitle:@"QEMU - (Press ctrl + alt to release 
Mouse)"];
+[normalWindow setTitle:@"QEMU - (Press ctrl + alt + g to release 
Mouse)"];
 }
 [self hideCursor];
 if (!isAbsoluteEnabled) {
-- 
2.13.5 (Apple Git-94)




[Qemu-devel] [PATCH v3 2/2] ui/cocoa.m: send ctrl-alt key combinations to guest if not used by QEMU

2017-11-02 Thread John Arbuckle
Send control-alt key combinations to the guest if not used by the user 
interface.

Signed-off-by: John Arbuckle <programmingk...@gmail.com>
---
v3 changes:
- Code is now keyboard layout aware

v2 changes:
- changed logic to use existing if case

 ui/cocoa.m | 41 -
 1 file changed, 20 insertions(+), 21 deletions(-)

diff --git a/ui/cocoa.m b/ui/cocoa.m
index e06aa9c65f..030479f4cd 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -619,29 +619,28 @@ - (void) handleEvent:(NSEvent *)event
 return;
 }
 
-// default
-
-// handle control + alt Key Combos (ctrl+alt+[1..9,g] is reserved 
for QEMU)
-if (([event modifierFlags] & NSEventModifierFlagControl) && 
([event modifierFlags] & NSEventModifierFlagOption)) {
+// console selection
+if (([event modifierFlags] & NSEventModifierFlagControl) &&
+([event modifierFlags] & NSEventModifierFlagOption) &&
+([[event charactersIgnoringModifiers] length] == 1) &&
+(isdigit([[event charactersIgnoringModifiers] 
characterAtIndex: 0]))) {
 NSString *keychar = [event charactersIgnoringModifiers];
-if ([keychar length] == 1) {
-char key = [keychar characterAtIndex:0];
-switch (key) {
-
-// enable graphic console
-case '1' ... '9':
-console_select(key - '0' - 1); /* ascii math */
-return;
-
-// release the mouse grab
-case 'g':
-[self ungrabMouse];
-return;
-}
-}
+char key = [keychar characterAtIndex:0];
+console_select(key - '0' - 1); /* ascii math */
+return;
+}
+
+// mouse ungrab
+else if (([event modifierFlags] & NSEventModifierFlagControl) &&
+ ([event modifierFlags] & NSEventModifierFlagOption) &&
+ ([[event charactersIgnoringModifiers] length] == 1) &&
+ ([[event charactersIgnoringModifiers] characterAtIndex: 
0] == 'g')) {
+[self ungrabMouse];
+return;
+}
 
-// handle keys for graphic console
-} else if (qemu_console_is_graphic(NULL)) {
+// send to guest
+else if (qemu_console_is_graphic(NULL)) {
 qemu_input_event_send_key_qcode(dcl->con, keycode, true);
 
 // handlekeys for Monitor
-- 
2.13.5 (Apple Git-94)




  1   2   >