Connect to running qemu instance with qemu monitor

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I'm having an instance of qemu running on Windows 7, running without an open terminal. Now I want to shutdown the machine with the name MyMachineName or add an USB-Device to it.
I need a scriptable solution. Libvirt is not a solution, because it has other disadvantages for my system.



Im looking for a magic line like:



qemu-monitor -connect=MyMachineName command="shutdown"


How can I do it?







share|improve this question






















  • Unless you've redirected the QEMU monitor to a device you can access via the command line (e.g., via -monitor <dev>), you can't connect to it via a script.
    – dsstorefile1
    Feb 26 at 19:59











  • So, you saying, that I can do the following: qemu-system-... -monitor "/dev/ttyMyConsol" and than echo "My QemuMonitorCommand" > /dev/ttyMyConsol and it will make qemu execute the command on that machine? but the only way to control the machine is the qemu-monitor?
    – Cutton Eye
    Feb 27 at 13:01















up vote
0
down vote

favorite












I'm having an instance of qemu running on Windows 7, running without an open terminal. Now I want to shutdown the machine with the name MyMachineName or add an USB-Device to it.
I need a scriptable solution. Libvirt is not a solution, because it has other disadvantages for my system.



Im looking for a magic line like:



qemu-monitor -connect=MyMachineName command="shutdown"


How can I do it?







share|improve this question






















  • Unless you've redirected the QEMU monitor to a device you can access via the command line (e.g., via -monitor <dev>), you can't connect to it via a script.
    – dsstorefile1
    Feb 26 at 19:59











  • So, you saying, that I can do the following: qemu-system-... -monitor "/dev/ttyMyConsol" and than echo "My QemuMonitorCommand" > /dev/ttyMyConsol and it will make qemu execute the command on that machine? but the only way to control the machine is the qemu-monitor?
    – Cutton Eye
    Feb 27 at 13:01













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I'm having an instance of qemu running on Windows 7, running without an open terminal. Now I want to shutdown the machine with the name MyMachineName or add an USB-Device to it.
I need a scriptable solution. Libvirt is not a solution, because it has other disadvantages for my system.



Im looking for a magic line like:



qemu-monitor -connect=MyMachineName command="shutdown"


How can I do it?







share|improve this question














I'm having an instance of qemu running on Windows 7, running without an open terminal. Now I want to shutdown the machine with the name MyMachineName or add an USB-Device to it.
I need a scriptable solution. Libvirt is not a solution, because it has other disadvantages for my system.



Im looking for a magic line like:



qemu-monitor -connect=MyMachineName command="shutdown"


How can I do it?









share|improve this question













share|improve this question




share|improve this question








edited Feb 26 at 11:11









Stefan M

8101617




8101617










asked Feb 26 at 11:07









Cutton Eye

1106




1106











  • Unless you've redirected the QEMU monitor to a device you can access via the command line (e.g., via -monitor <dev>), you can't connect to it via a script.
    – dsstorefile1
    Feb 26 at 19:59











  • So, you saying, that I can do the following: qemu-system-... -monitor "/dev/ttyMyConsol" and than echo "My QemuMonitorCommand" > /dev/ttyMyConsol and it will make qemu execute the command on that machine? but the only way to control the machine is the qemu-monitor?
    – Cutton Eye
    Feb 27 at 13:01

















  • Unless you've redirected the QEMU monitor to a device you can access via the command line (e.g., via -monitor <dev>), you can't connect to it via a script.
    – dsstorefile1
    Feb 26 at 19:59











  • So, you saying, that I can do the following: qemu-system-... -monitor "/dev/ttyMyConsol" and than echo "My QemuMonitorCommand" > /dev/ttyMyConsol and it will make qemu execute the command on that machine? but the only way to control the machine is the qemu-monitor?
    – Cutton Eye
    Feb 27 at 13:01
















Unless you've redirected the QEMU monitor to a device you can access via the command line (e.g., via -monitor <dev>), you can't connect to it via a script.
– dsstorefile1
Feb 26 at 19:59





Unless you've redirected the QEMU monitor to a device you can access via the command line (e.g., via -monitor <dev>), you can't connect to it via a script.
– dsstorefile1
Feb 26 at 19:59













So, you saying, that I can do the following: qemu-system-... -monitor "/dev/ttyMyConsol" and than echo "My QemuMonitorCommand" > /dev/ttyMyConsol and it will make qemu execute the command on that machine? but the only way to control the machine is the qemu-monitor?
– Cutton Eye
Feb 27 at 13:01





So, you saying, that I can do the following: qemu-system-... -monitor "/dev/ttyMyConsol" and than echo "My QemuMonitorCommand" > /dev/ttyMyConsol and it will make qemu execute the command on that machine? but the only way to control the machine is the qemu-monitor?
– Cutton Eye
Feb 27 at 13:01











1 Answer
1






active

oldest

votes

















up vote
2
down vote



accepted










Someone might be able to chime in with a proper command for operating on TTYs, but I'll post a solution in the meantime involving the network.



There are a couple options for redirecting the QEMU monitor. One way is to have QEMU offer access to its monitor via telnet:



$ qemu-system-i386 -monitor telnet:127.0.0.1:55555,server,nowait;


Then, QEMU can be scripted by piping commands to telnet. This is fine as long as the output of commands can be discarded since the telnet session will probably close too quickly for visual feedback:



$ echo system_powerdown |telnet 127.0.0.1 55555
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
Connection closed by foreign host.
$ _ # qemu sends the guest an ACPI shutdown signal


If the output of the commands executed on the monitor need to be collected, a TCP session can be used instead:



$ qemu-system-i386 -monitor tcp:127.0.0.1:55555,server,nowait;


Then, commands can be sent to the listening monitor via netcat or a similar utility:



$ echo info kvm |nc -N 127.0.0.1 55555
QEMU 2.11.0 monitor - type 'help' for more information
(qemu) info kvm
kvm support: enabled
(qemu) $ echo system_powerdown |nc -N 127.0.0.1 55555
QEMU 2.11.0 monitor - type 'help' for more information
(qemu) system_powerdown
(qemu) $ # hit return
$ _ # qemu sends the guest an ACPI shutdown signal


Here is a link to partial documentation of QEMU monitor commands: https://en.wikibooks.org/wiki/QEMU/Monitor






share|improve this answer






















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );








     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f426652%2fconnect-to-running-qemu-instance-with-qemu-monitor%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    2
    down vote



    accepted










    Someone might be able to chime in with a proper command for operating on TTYs, but I'll post a solution in the meantime involving the network.



    There are a couple options for redirecting the QEMU monitor. One way is to have QEMU offer access to its monitor via telnet:



    $ qemu-system-i386 -monitor telnet:127.0.0.1:55555,server,nowait;


    Then, QEMU can be scripted by piping commands to telnet. This is fine as long as the output of commands can be discarded since the telnet session will probably close too quickly for visual feedback:



    $ echo system_powerdown |telnet 127.0.0.1 55555
    Trying 127.0.0.1...
    Connected to 127.0.0.1.
    Escape character is '^]'.
    Connection closed by foreign host.
    $ _ # qemu sends the guest an ACPI shutdown signal


    If the output of the commands executed on the monitor need to be collected, a TCP session can be used instead:



    $ qemu-system-i386 -monitor tcp:127.0.0.1:55555,server,nowait;


    Then, commands can be sent to the listening monitor via netcat or a similar utility:



    $ echo info kvm |nc -N 127.0.0.1 55555
    QEMU 2.11.0 monitor - type 'help' for more information
    (qemu) info kvm
    kvm support: enabled
    (qemu) $ echo system_powerdown |nc -N 127.0.0.1 55555
    QEMU 2.11.0 monitor - type 'help' for more information
    (qemu) system_powerdown
    (qemu) $ # hit return
    $ _ # qemu sends the guest an ACPI shutdown signal


    Here is a link to partial documentation of QEMU monitor commands: https://en.wikibooks.org/wiki/QEMU/Monitor






    share|improve this answer


























      up vote
      2
      down vote



      accepted










      Someone might be able to chime in with a proper command for operating on TTYs, but I'll post a solution in the meantime involving the network.



      There are a couple options for redirecting the QEMU monitor. One way is to have QEMU offer access to its monitor via telnet:



      $ qemu-system-i386 -monitor telnet:127.0.0.1:55555,server,nowait;


      Then, QEMU can be scripted by piping commands to telnet. This is fine as long as the output of commands can be discarded since the telnet session will probably close too quickly for visual feedback:



      $ echo system_powerdown |telnet 127.0.0.1 55555
      Trying 127.0.0.1...
      Connected to 127.0.0.1.
      Escape character is '^]'.
      Connection closed by foreign host.
      $ _ # qemu sends the guest an ACPI shutdown signal


      If the output of the commands executed on the monitor need to be collected, a TCP session can be used instead:



      $ qemu-system-i386 -monitor tcp:127.0.0.1:55555,server,nowait;


      Then, commands can be sent to the listening monitor via netcat or a similar utility:



      $ echo info kvm |nc -N 127.0.0.1 55555
      QEMU 2.11.0 monitor - type 'help' for more information
      (qemu) info kvm
      kvm support: enabled
      (qemu) $ echo system_powerdown |nc -N 127.0.0.1 55555
      QEMU 2.11.0 monitor - type 'help' for more information
      (qemu) system_powerdown
      (qemu) $ # hit return
      $ _ # qemu sends the guest an ACPI shutdown signal


      Here is a link to partial documentation of QEMU monitor commands: https://en.wikibooks.org/wiki/QEMU/Monitor






      share|improve this answer
























        up vote
        2
        down vote



        accepted







        up vote
        2
        down vote



        accepted






        Someone might be able to chime in with a proper command for operating on TTYs, but I'll post a solution in the meantime involving the network.



        There are a couple options for redirecting the QEMU monitor. One way is to have QEMU offer access to its monitor via telnet:



        $ qemu-system-i386 -monitor telnet:127.0.0.1:55555,server,nowait;


        Then, QEMU can be scripted by piping commands to telnet. This is fine as long as the output of commands can be discarded since the telnet session will probably close too quickly for visual feedback:



        $ echo system_powerdown |telnet 127.0.0.1 55555
        Trying 127.0.0.1...
        Connected to 127.0.0.1.
        Escape character is '^]'.
        Connection closed by foreign host.
        $ _ # qemu sends the guest an ACPI shutdown signal


        If the output of the commands executed on the monitor need to be collected, a TCP session can be used instead:



        $ qemu-system-i386 -monitor tcp:127.0.0.1:55555,server,nowait;


        Then, commands can be sent to the listening monitor via netcat or a similar utility:



        $ echo info kvm |nc -N 127.0.0.1 55555
        QEMU 2.11.0 monitor - type 'help' for more information
        (qemu) info kvm
        kvm support: enabled
        (qemu) $ echo system_powerdown |nc -N 127.0.0.1 55555
        QEMU 2.11.0 monitor - type 'help' for more information
        (qemu) system_powerdown
        (qemu) $ # hit return
        $ _ # qemu sends the guest an ACPI shutdown signal


        Here is a link to partial documentation of QEMU monitor commands: https://en.wikibooks.org/wiki/QEMU/Monitor






        share|improve this answer














        Someone might be able to chime in with a proper command for operating on TTYs, but I'll post a solution in the meantime involving the network.



        There are a couple options for redirecting the QEMU monitor. One way is to have QEMU offer access to its monitor via telnet:



        $ qemu-system-i386 -monitor telnet:127.0.0.1:55555,server,nowait;


        Then, QEMU can be scripted by piping commands to telnet. This is fine as long as the output of commands can be discarded since the telnet session will probably close too quickly for visual feedback:



        $ echo system_powerdown |telnet 127.0.0.1 55555
        Trying 127.0.0.1...
        Connected to 127.0.0.1.
        Escape character is '^]'.
        Connection closed by foreign host.
        $ _ # qemu sends the guest an ACPI shutdown signal


        If the output of the commands executed on the monitor need to be collected, a TCP session can be used instead:



        $ qemu-system-i386 -monitor tcp:127.0.0.1:55555,server,nowait;


        Then, commands can be sent to the listening monitor via netcat or a similar utility:



        $ echo info kvm |nc -N 127.0.0.1 55555
        QEMU 2.11.0 monitor - type 'help' for more information
        (qemu) info kvm
        kvm support: enabled
        (qemu) $ echo system_powerdown |nc -N 127.0.0.1 55555
        QEMU 2.11.0 monitor - type 'help' for more information
        (qemu) system_powerdown
        (qemu) $ # hit return
        $ _ # qemu sends the guest an ACPI shutdown signal


        Here is a link to partial documentation of QEMU monitor commands: https://en.wikibooks.org/wiki/QEMU/Monitor







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Feb 27 at 14:39

























        answered Feb 27 at 14:30









        dsstorefile1

        1,576212




        1,576212






















             

            draft saved


            draft discarded


























             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f426652%2fconnect-to-running-qemu-instance-with-qemu-monitor%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Displaying single band from multi-band raster using QGIS

            How many registers does an x86_64 CPU actually have?