Re: New vendor branch for FreeBSD on Hyper-V. Please review.

2013-03-27 Thread Alexander Motin

Hi.

As ATA driver maintainer I've took a look on that part of the code. I 
have some comments about what I see. Please keep me CC'd, as I am 
normally not on this list.


1) You are using machine dependent function do_cpuid() in machine 
independent ATA code. It will just not build on any architecture except 
amd64 and i386. You should periodically run `make universe` to be sure 
that you code does not breaks the build for some rare archs. As minimum 
that code should be wrapped into respective #ifdef's, but I would prefer 
it to be moved out somewhere to MD code (like MD code that does general 
VM detection now), as this doesn't really belong to the ATA driver.


2) You are disabling "ad" ATA disk driver. Here I have two objections:
 a) "ad" driver is obsoleted and not used since FreeBSD 9.0, when 
CAM-based ATA stack replaces it completely, wrapping only controller 
driver parts of old ata(4) into CAM SIM, which is now only one of four 
ATA/SATA SIMs in the system. Your change is effectively null now.
 b) I believe you are using wrong approach here. I believe instead of 
completely disabling disk driver you should disable only specific 
Hyper-V emulated ATA controller device instance. I've never used 
Hyper-V, but I guess it should support PCI device pass-through. Just 
imagine what happen if somebody wish to pass-through ATA/SATA 
controller? You will disable it also.


3) Looking on what I suppose is "Fast IDE" driver in the file 
hv_storvsc_drv_freebsd.c, it seems more like cut-down SAS, then IDE. It 
doesn't support ATA commands, it reports itself to CAM as SAS. The only 
differences I see are disabling LUNs and limiting queue to 1 slot. Just 
a smile: it is neither really "Fast" nor at all "IDE". :)


4) In you SAS driver in storvsc_action() you have hardcoded 
CTS_SCSI_FLAGS_TAG_ENB flag. While I guess it should not cause any 
problems, it wont allow user to control it if he decide to experiment 
with disabling it.


--
Alexander Motin
___
freebsd-virtualization@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-virtualization
To unsubscribe, send any mail to 
"freebsd-virtualization-unsubscr...@freebsd.org"


KVM with freeBSD and SR-IOV vlan doesn't working!

2013-03-27 Thread kindule
Recently, we use KVM and SR-IOV in our project. And we choose freeBSD10 as
the guest os.As we use the ip address in the igb0 of our freeBSD10 guest, it
working no problem.However when i use vlan in our igb0 of the freeBSD10
guest,we can see the vlan assigned right and we can ping the vlan address
without problem.But we add a gateway of the vlan area.we can't connnected to
the gateway.
there are some os messages:
Host: Debian 7.0 and KVM 1.2
Guest: FreeBSD10-current

And thanks for your help!



--
View this message in context: 
http://freebsd.1045724.n5.nabble.com/KVM-with-freeBSD-and-SR-IOV-vlan-doesn-t-working-tp5799323.html
Sent from the freebsd-virtualization mailing list archive at Nabble.com.
___
freebsd-virtualization@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-virtualization
To unsubscribe, send any mail to 
"freebsd-virtualization-unsubscr...@freebsd.org"


suspend/resume on BHyVe

2013-03-27 Thread Takuya ASADA
Hi,

I had some discussion with Iori about the project since last year, and now I'm
suggesting him to apply Google Summer of Code'13 with the project.
(GSoC'13 will start next month)

 > For this, I think those below must be implemented.
> >
> >   - virtual machine state command interface
> >   - saving registers per CPU
> >   - dumping physical memory
> >   - saving virt-io and other device emulation state
> >
> >
> > To save registers, the sysctl used in bhyvectl (vmmctl command
> > previously) is helpful,



> Maybe he meant ioctl.



> however, it's interface is no good because getting register value
> > cause a sysctl call
> > so to context-switch per one register, and for getting all registers,
> > it's not efficient.

> I think it's more preferable to make a struct to set or unset boolean
> > fields per register,
> > to tell which registers kernel should return, and kernel returns those
> > state with struct vmxctx.
> >
> > struct vmxctx is such.
> >  struct vmxctx {
> > register_t  tmpstk[32]; /* vmx_return() stack */
> > register_t  tmpstktop;
> >
> > register_t  guest_rdi;  /* Guest state */
> > register_t  guest_rsi;
> > :
> > :


It looks we don't really have to take care register values on VMCS on here,
just registers on vmxctx is enough(described below).
Then, how about to add vmxctx dumping ioctl?


> >
> >
> > And, considering memory dump, /dev/vmm/vmname is a file that is a map
> > of guest memory,
> > so memory dump doesn't seem hard, just stop vm, write back all guest
> > cache, and copy
> > memory file to a regular file.
> >
> > Finally, I don't know much about device state, but I think there must
> > some state to be saved, like
> > network stack.
> >
> > I'm not sure I wrote former, so I appreciate your ideas and suggestions.
> >
>
> I think that you are on the right track.
>
> A brute force way of figuring out all the state must be saved is to
> look at all the initialization functions that are called when a vm and
> a vcpu are created. So, this would be vm_create() and vcpu_init() in
> the kernel module.
>
> There is also the hardware assist state that is maintained by the
> processor (VT-x or SVM) and this includes things like guest
> interruptibility, guest run state etc. I am assuming that it would be
> sufficient to save the VMCS page after telling the processor to flush
> any state it may be caching on chip.


 I think, just dump whole VMCS page after calling VMCLEAR instruction is
easiest way to do this.
(I also considered to dump only necessary values on VMCS by VMREAD
instruction, but maybe it's easy to break guest state mistakenly, and we
don't get advantage by doing that way.)

Then maybe we need VMCS dumping ioctl here.

There is also emulated pci bus, virtio devices and legacy isa device
> state that would need to be saved by the userspace 'bhyve' process.


What is the necessary operation for virtio devices to suspend/resume?
Maybe dump all rings of the devices?
It doesn't have registers, right?


> And finally there is the matter of how to communicate with 'bhyve'
> process that it needs to suspend the virtual machine and write its
> state to disk - perhaps a signal would be good enough place to start.


How about this idea:
bhyvectl sends VM_SUSPEND ioctl.
If the guests is in VMX non-root mode, VM_SUSPEND ioctl handler sends IPI
to interrupt the guest thread.
Then the guest thread breaks vmx_run() loop, exit to userland with exitcode
VM_EXITCODE_SUSPEND.

Or, if the guests is not in VM_RUN ioctl but performing userland work(such
as running virtio host-side driver), maybe you just need to wait bhyve
process sends VM_RUN ioctl.
When bhyve sends VM_RUN ioctl, vmm.ko should not perform VMEnter.
It should just returns VM_EXITCODE_SUSPEND.

On both cases, vmm.ko returns VM_EXITCODE_SUSPEND at the end.
Then bhyve process can perform suspend action in VM_EXITCODE_SUSPEND
handler.

I think this is simple.


> This certainly sounds like an interesting and challenging project and
> we would be happy to help in any way we can.
>
> best
> Neel
>
> > Thanks, Iori.
> > ___
> > freebsd-virtualization@freebsd.org mailing list
> > http://lists.freebsd.org/mailman/listinfo/freebsd-virtualization
> > To unsubscribe, send any mail to "
> freebsd-virtualization-unsubscr...@freebsd.org"
> ___
> freebsd-virtualization@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-virtualization
> To unsubscribe, send any mail to "
> freebsd-virtualization-unsubscr...@freebsd.org"
___
freebsd-virtualization@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-virtualization
To unsubscribe, send any mail to 
"freebsd-virtualization-unsubscr...@freebsd.org"


Re: suspend/resume on BHyVe

2013-03-27 Thread Takuya ASADA
Hi,

> A brute force way of figuring out all the state must be saved is to
> look at all the initialization functions that are called when a vm and
> a vcpu are created. So, this would be vm_create() and vcpu_init() in
> the kernel module.

I think these things are need to dump by resume action:

- guest memory area
- struct vmxctx
- VMCS page
- VLAPIC registers
- virtio device state (dumping virtio ring?)
- current configuration of bhyve process (with was configured by an
arguments passed to bhyve process)

Maybe there's more.
___
freebsd-virtualization@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-virtualization
To unsubscribe, send any mail to 
"freebsd-virtualization-unsubscr...@freebsd.org"