qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Denis V. Lunev" <den@openvz.org>
To: "Gabriel L. Somlo" <gsomlo@gmail.com>
Cc: qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com
Subject: Re: [Qemu-devel] RFC: Proposal to add QEMU "Guest Environment Variables"
Date: Tue, 3 Feb 2015 23:23:22 +0300	[thread overview]
Message-ID: <54D12E3A.3050503@openvz.org> (raw)
In-Reply-To: <20150203201444.GS3354@HEDWIG.INI.CMU.EDU>

On 03/02/15 23:14, Gabriel L. Somlo wrote:
> Hi Denis,
>
> On Tue, Feb 03, 2015 at 10:14:03PM +0300, Denis V. Lunev wrote:
>> On 03/02/15 22:09, Gabriel L. Somlo wrote:
>>>
>>> I'm interested in adding a way for a host to pass environment variables
>>> into a qemu guest VM -- analogous to setting environment variables for
>>> a process to access via getenv() and friends.
>>>
>>> The QEMU Guest Agent (QGA) does not appear to quite fit the bill, at
>>> least not in its current form: The agent must have been successfully
>>> started on the guest before the host would have to connect to it (in
>>> a separate act from just starting the guest in the first place), and
>>> get it to execute any hypothetical commands to configure or otherwise
>>> influence the guest.
>>>
>>> For this functionality to really resemble the way environment variables
>>> are used, environment information should be provided as part of the QEMU
>>> command line, without the requirement to make a separate/subsequent
>>> connection to the guest agent. For example:
>>>
>>>      qemu-system-x86_64 -guest-env="VAR1=value1;VAR2=value 2" -hda image.qcow2
>>>
>>> Once the guest is started, it should be possible to query the guest
>>> environment with something like:
>>>
>>>      $ qemu-guest-env get VAR1
>>>      value1
>>>
>>>      $ qemu-guest-env get VAR2
>>>      value 2
>>> [...]
>>
>> I think that you can do this through guest write/guest exec commands.
>> You can configure service start to perform it is a proper way through
>> guest read/guest write and after that restart the agent.
>
> Are these supposed to be commands issued from the qemu monitor prompt
> (or qmp) ? My Google-fu didn't help too much either :)
>
> The main idea is to be able to provide environment data to a guest
> at start time (on the qemu command line), and not have to worry about
> connecting back to it (via monitor prompt, qmp, if/when it starts the
> guest agent, etc) to pass more information to it later on.
>
> I'm probably misunderstanding what you said, though, so please
> clarify...
>
> Thanks much,
> --Gabriel
>
QEMU guest agent starts as a service inside the guest. Its startup
is controlled through standard Unix scripts. You can modify these
scrips from the host side and (hopefully) restart agent.

The modification could be made using

##
# @GuestFileRead
#
# Result of guest agent file-read operation
#
# @count: number of bytes read (note: count is *before*
#         base64-encoding is applied)
#
# @buf-b64: base64-encoded bytes read
#
# @eof: whether EOF was encountered during read operation.
#
# Since: 0.15.0
##
{ 'type': 'GuestFileRead',
   'data': { 'count': 'int', 'buf-b64': 'str', 'eof': 'bool' } }

##
# @GuestFileWrite
#
# Result of guest agent file-write operation
#
# @count: number of bytes written (note: count is actual bytes
#         written, after base64-decoding of provided buffer)
#
# @eof: whether EOF was encountered during write operation.
#
# Since: 0.15.0
##
{ 'type': 'GuestFileWrite',
   'data': { 'count': 'int', 'eof': 'bool' } }

Den

  reply	other threads:[~2015-02-03 20:23 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-03 19:09 [Qemu-devel] RFC: Proposal to add QEMU "Guest Environment Variables" Gabriel L. Somlo
2015-02-03 19:14 ` Denis V. Lunev
2015-02-03 20:14   ` Gabriel L. Somlo
2015-02-03 20:23     ` Denis V. Lunev [this message]
2015-02-03 19:26 ` Eric Blake
2015-02-03 20:54   ` Gabriel L. Somlo
2015-02-03 20:11 ` Michael Roth
2015-02-03 21:38   ` Gabriel L. Somlo
2015-02-03 21:49     ` Denis V. Lunev
2015-02-03 22:14       ` Gabriel L. Somlo
2015-02-03 22:08     ` Michael Roth
2015-02-04  9:31     ` Daniel P. Berrange
2015-02-04 15:20       ` Gabriel L. Somlo
2015-02-04 15:24         ` Daniel P. Berrange
2015-02-04 15:59           ` Gabriel L. Somlo
2015-02-04 16:12             ` Daniel P. Berrange
2015-02-04  9:29 ` Daniel P. Berrange
2015-02-04 15:55 ` Christopher Covington
2015-02-04 16:00 ` Richard W.M. Jones
2015-02-04 16:06   ` Gabriel L. Somlo

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=54D12E3A.3050503@openvz.org \
    --to=den@openvz.org \
    --cc=gsomlo@gmail.com \
    --cc=mdroth@linux.vnet.ibm.com \
    --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).