qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Programmingkid <programmingkidx@gmail.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-devel qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH] ui/cocoa.m: Add Mount image file menu item
Date: Tue, 8 Sep 2015 12:39:43 -0400	[thread overview]
Message-ID: <26B5A68C-92C9-4528-BA17-4A282DCFF035@gmail.com> (raw)
In-Reply-To: <CAFEAcA_wQePZkNofdxoXn7bVhNziHY3Fb8xs=60D9kF2oXquXg@mail.gmail.com>


On Sep 8, 2015, at 12:17 PM, Peter Maydell wrote:

> On 2 September 2015 at 01:56, Programmingkid <programmingkidx@gmail.com> 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.
>> 
>> 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.
>> 
>> Signed-off-by: John Arbuckle <programmingkidx@gmail.com>
>> 
>> ---
>> ui/cocoa.m |  212
>> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
>> 1 files changed, 210 insertions(+), 1 deletions(-)
>> 
>> 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
>> 
>> 
>> 
>> #define cgrect(nsrect) (*(CGRect *)&(nsrect))
>> +#define USB_DISK_ID "USB_DISK"
>> +#define EJECT_IMAGE_FILE_TAG 2099
>> 
>> 
>> 
>> typedef struct {
>>     int width;
>> @@ -263,6 +266,43 @@ static void handleAnyDeviceErrors(Error * err)
>>     }
>> }
>> 
>> 
>> 
>> +/* 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 = 0;
>> +        /* Find the monitor console */
>> +        while (qemu_console_lookup_by_index(index) != NULL) {
>> +            consoleName =
>> qemu_console_get_label(qemu_console_lookup_by_index(index));
>> +            if(strstr(consoleName, "monitor")) {
>> +                monitor = 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 = 0; index < strlen(commandString); index++) {
>> +        kbd_put_keysym_console(monitor, commandString[index]);
>> +    }
> 
> 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? 

Would you know what function I should use in place of the commands the patch uses?

> 
> What happens on machines with no USB bus?

I will add code that checks for USB support before using this feature. 

Thanks for reviewing my patch.

  reply	other threads:[~2015-09-08 16:39 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-02  0:56 [Qemu-devel] [PATCH] ui/cocoa.m: Add Mount image file menu item Programmingkid
2015-09-02  9:05 ` Markus Armbruster
2015-09-08 16:17 ` Peter Maydell
2015-09-08 16:39   ` Programmingkid [this message]
2015-09-08 16:54     ` Peter Maydell
2015-09-08 18:46     ` Markus Armbruster
2015-09-09  3:02       ` Programmingkid
2015-09-09  7:29         ` Markus Armbruster
2015-09-09 21:37           ` Programmingkid
2015-09-09 22:25             ` Eric Blake
2015-09-09 22:31               ` Eric Blake
2015-09-09 23:35                 ` Programmingkid
2015-09-09 23:34               ` Programmingkid
2015-09-10  7:17                 ` Markus Armbruster
2015-09-10  3:28           ` Programmingkid
2015-09-10  7:21             ` Markus Armbruster
2015-09-10 16:22               ` Programmingkid
2015-09-10 17:15                 ` Markus Armbruster
2015-09-10 17:40                   ` Programmingkid
2015-09-11  7:09                     ` Markus Armbruster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=26B5A68C-92C9-4528-BA17-4A282DCFF035@gmail.com \
    --to=programmingkidx@gmail.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).