From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45480) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZLvx-0006h3-KL for qemu-devel@nongnu.org; Tue, 08 Sep 2015 12:39:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZZLvu-0002Y5-CU for qemu-devel@nongnu.org; Tue, 08 Sep 2015 12:39:49 -0400 Received: from mail-qg0-x235.google.com ([2607:f8b0:400d:c04::235]:36382) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZZLvu-0002Xy-8w for qemu-devel@nongnu.org; Tue, 08 Sep 2015 12:39:46 -0400 Received: by qgx61 with SMTP id 61so87389834qgx.3 for ; Tue, 08 Sep 2015 09:39:46 -0700 (PDT) Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii From: Programmingkid In-Reply-To: Date: Tue, 8 Sep 2015 12:39:43 -0400 Content-Transfer-Encoding: quoted-printable Message-Id: <26B5A68C-92C9-4528-BA17-4A282DCFF035@gmail.com> References: <65D87A2B-B94F-4236-A9BB-D0F0B7FCF96B@gmail.com> Subject: Re: [Qemu-devel] [PATCH] ui/cocoa.m: Add Mount image file menu item List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: qemu-devel qemu-devel On Sep 8, 2015, at 12:17 PM, Peter Maydell wrote: > On 2 September 2015 at 01:56, Programmingkid = wrote: >> Add "Mount Image File..." and a "Eject Image File" menu items to >> cocoa interface. This patch makes sharing files between the >> host and the guest user-friendly. >>=20 >> The "Mount Image File..." menu item displays a dialog box having the >> user pick an image file to use in QEMU. The image file is setup as >> a USB flash drive. The user can do the equivalent of removing the >> flash drive by selecting the file in the "Eject Image File" submenu. >>=20 >> Signed-off-by: John Arbuckle >>=20 >> --- >> ui/cocoa.m | 212 >> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- >> 1 files changed, 210 insertions(+), 1 deletions(-) >>=20 >> diff --git a/ui/cocoa.m b/ui/cocoa.m >> index 334e6f6..6c0ec18 100644 >> --- a/ui/cocoa.m >> +++ b/ui/cocoa.m >> @@ -52,6 +52,9 @@ >> #endif >>=20 >>=20 >>=20 >> #define cgrect(nsrect) (*(CGRect *)&(nsrect)) >> +#define USB_DISK_ID "USB_DISK" >> +#define EJECT_IMAGE_FILE_TAG 2099 >>=20 >>=20 >>=20 >> typedef struct { >> int width; >> @@ -263,6 +266,43 @@ static void handleAnyDeviceErrors(Error * err) >> } >> } >>=20 >>=20 >>=20 >> +/* Sends a command to the monitor console */ >> +static void sendMonitorCommand(const char * commandString) >> +{ >> + int index; >> + char * consoleName; >> + static QemuConsole *monitor; >> + >> + /* If the monitor console hasn't been found yet */ >> + if(!monitor) { >> + index =3D 0; >> + /* Find the monitor console */ >> + while (qemu_console_lookup_by_index(index) !=3D NULL) { >> + consoleName =3D >> qemu_console_get_label(qemu_console_lookup_by_index(index)); >> + if(strstr(consoleName, "monitor")) { >> + monitor =3D qemu_console_lookup_by_index(index); >> + break; >> + } >> + index++; >> + } >> + } >> + >> + /* If the monitor console was not found */ >> + if(!monitor) { >> + NSBeep(); >> + QEMU_Alert(@"Failed to find the monitor console!"); >> + return; >> + } >> + >> + /* send each letter in the commandString to the monitor */ >> + for (index =3D 0; index < strlen(commandString); index++) { >> + kbd_put_keysym_console(monitor, commandString[index]); >> + } >=20 > We're doing this by sending a string to the human monitor? > That definitely doesn't seem like the right way to do this > (and there might not even be a human monitor to talk to)... Under what situation is the human monitor not available?=20 Would you know what function I should use in place of the commands the = patch uses? >=20 > What happens on machines with no USB bus? I will add code that checks for USB support before using this feature.=20= Thanks for reviewing my patch.=