Dear Friends,
Thanks for your suggestions. I have implemented them; all works!
Now the security module at the hypervisor (KVM) analyzed the data coming from guest and
decided that this guest malfunctions and must be rebooted. When rebooting I address the VM
being rebooted by its name: first getting the domain by name (virDomainLookupByName) and
then reboot the domain (virDomainReset).
The problem is: how can I get the VM name, having the malfunctioning VCPU (struct
kvm_vcpu) as the context ?
I retrieve VCPUs using the following loop:
raw_spin_lock(vm_lock);
list_for_each_entry(kvm, vms_list, vm_list)
{
for (i = 0; i < kvm->online_vcpus.counter; i++)
{
...
}
}
raw_spin_unlock(vm_lock);
Thanks in advance,
Alex BInun
On Wed 28 May 21:44 2014 Dave Allan wrote:
On Wed, May 28, 2014 at 11:28:19AM -0600, Eric Blake wrote:
> On 05/28/2014 09:14 AM, Alexander Binun wrote:
>
> [can you convince your mailer to wrap long lines?]
>
> >
> > I have a program running on a VM guest. Its output is valuable (for VM
introspection) so I want to let the host module know about it. I prefer to redirect '
stdio" of a guest into a device at the host (a text file or my device that has the
name "mydev"
> > and the driver is written for it).
> >
> > I have the XML definition file for my VM in /etc/libvirt/qemu. I have added the
section:
> >
> > <serial type="file">
> > <source path="/var/log/vm/vml.log"/>
> > <target port="0"/>
> > </serial>
> >
> > into the /devices section.
> >
> > That is I want the stdio to be streamed into the file /var/log/vm/vml.log at
the host.
> >
> > Then I run simple textual commands at the guest (ls, pwd and so on).
>
> How are you getting into your guest to run those commands? Did you
> connect to your guest's serial console, or is it in a gui window, or via
> an ssh session, or...? Are you sure the commands you are executing have
> the guest's /dev/ttyS0 as their stdout?
Your xml is correct and I think Eric's suggestion is right: if I put
that <serial> snippet into a guest's XML and then echo "foo" >
/dev/ttyS0 in the guest, I see "foo" in the host vml.log.
> > But I do not see /var/log/vm/vml.log created at the host.
>
> I'm not sure whether libvirt will pre-create the file, or whether it
> insists that the file already exists. Maybe others can chime in. I know
> Dave Allan has done some work with python scripts that faithfully
> capture all text output to the guest's serial console, although I don't
> have a handy link to that sample script.
The example script is consolecallback.py[1] but it really deals more
with auto connecting to a serial console when a VM is booted than with
doing anything special with the output, although it's useful if you
have a VM going up and down and you want all its console output.
Dave
[1]
http://libvirt.org/git/?p=libvirt-python.git;a=blob;f=examples/consolecal...
> --
> Eric Blake eblake redhat com +1-919-301-3266
> Libvirt virtualization library
http://libvirt.org
>