<div dir="ltr">So the suitable way of doing this will be checking for `VIR_CPU_TYPE_HOST`<div>and perform a comparison in this case and still return IDENTICAL for all other</div><div>cases right? Then the upper layer caller(like OpenStack Nova) will have to</div><div>pass source host cpu info as a parameter. </div><div><br></div><div>BR,</div><div><br></div><div>Zhenyu<br><div><div><br></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Sep 7, 2020 at 7:16 PM Jiri Denemark <<a href="mailto:jdenemar@redhat.com">jdenemar@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Mon, Sep 07, 2020 at 09:21:02 +0800, Zhenyu Zheng wrote:<br>
> Thanks alot for the reply,<br>
> <br>
> This sounds like a valid use case (not sure it is that useful), but we<br>
> > need to be careful. But we should make sure implementing this does not<br>
> > break anything. This means, we need to do different things depending on<br>
> > the type of the CPU definition we are asked to compare. Guest CPU<br>
> > definitions should keep the old behaviour (return IDENTICAL) and host<br>
> > CPU definitions can be compared to the host CPU. But when doing so,<br>
> > don't get too influenced by x86 code, which I believe is way too<br>
> > complicated for ARM. Specifically you don't need to create armCompute<br>
> > and mess with guestData and other stuff there as all you want to do is<br>
> > compare the two CPU definitions. In x86 the same function is used for<br>
> > several things, but that's not the case for ARM.<br>
> <br>
> <br>
> for this, what I have in mind now is that we can check<br>
> `VIR_CPU_MODE_HOST_PASSTHROUGH`<br>
> and if that is the case, we compare CPU vendors and models to allow only<br>
> identical definitions to pass, like the implementation of<br>
> <a href="https://gitlab.com/libvirt/libvirt/-/blob/master/src/cpu/cpu_ppc64.c#L505" rel="noreferrer" target="_blank">https://gitlab.com/libvirt/libvirt/-/blob/master/src/cpu/cpu_ppc64.c#L505</a> ,<br>
<br>
This doesn't sound like a good idea. PPC is quite special in the way it<br>
uses host-model and host-passthrough. But anyway, it's actually easier<br>
to just return IDENTICAL for host-passthrough CPUs (and all other guest<br>
CPUs) than copying the host CPU from capabilities and comparing it to<br>
itself.<br>
<br>
> (this is because when a VM is in host-passthrough mode, its' CPU xml<br>
> reflects the original host CPU<br>
> definition, and we actually compare the source host and destination host<br>
> CPU definitions,<br>
<br>
The CPU definition of a domain with host-passthrough remains the same.<br>
That is, it doesn't reflect the original host CPU definition, it's still<br>
just host-passthrough. The only way to compare source and destinations<br>
host CPUs is by taking the host CPU def from one host and passing it to<br>
cpu-compare called on the other host.<br>
<br>
Jirka<br>
<br>
</blockquote></div>