* Re: [Qemu-devel] [PATCH 0/2] usb-ccid device (v2)
[not found] <593949580.216281286900989465.JavaMail.root@zmail06.collab.prod.int.phx2.redhat.com>
@ 2010-10-12 16:43 ` Alon Levy
2010-10-12 16:49 ` Anthony Liguori
0 siblings, 1 reply; 14+ messages in thread
From: Alon Levy @ 2010-10-12 16:43 UTC (permalink / raw)
To: Anthony Liguori; +Cc: qemu-devel
----- "Anthony Liguori" <anthony@codemonkey.ws> wrote:
> On 10/12/2010 11:03 AM, Alon Levy wrote:
> > ----- "Anthony Liguori"<anthony@codemonkey.ws> wrote:
> >
> >
> >> On 10/12/2010 07:58 AM, Alon Levy wrote:
> >>
> >>> This patch adds a new device, it is described in full in the
> second
> >>>
> >> patch
> >>
> >>> intro and also in the documentation in docs. In brief it provides
> a
> >>>
> >> standard
> >>
> >>> smart card reader device.
> >>>
> >>> The first patch is the configure change and docs.
> >>> The second patch contains the actual device, I couldn't figure out
> a
> >>>
> >> good
> >>
> >>> way to split it to ease review.
> >>>
> >>> v2 changed:
> >>> * all QSIMPLEQ turned into fixed sized rings
> >>> * all allocated buffers turned into fixed size buffers
> >>> * added migration support
> >>> * added a message to tell client qemu has migrated to ip:port
> >>> * for lack of monitor commands ip:port are 0:0, which causes
> the
> >>>
> >> updated
> >>
> >>> vscclient to connect to one port higher on the same host.
> will
> >>>
> >> add monitor
> >>
> >>> commands in a separate patch. tested with current setup.
> >>>
> >>>
> >> This is way too much magic to live within a device. Devices
> manage
> >> reconnecting themselves during migration. When you create the
> >> destination qemu instance, you specify what to connect to.
> >>
> >> IOW,
> >>
> >> On the source:
> >>
> >> qemu -chardev tcp:localhost:1025,id=foo -usbdevice
> ccid,chardev=foo
> >> ...
> >>
> >> On the destination:
> >>
> >> qemu -chardev tcp:localhost:1026,id=foo -usbdevice
> ccid,chardev=foo
> >> -incoming tcp:0.0.0.0:1024 ...
> >>
> >> A connection happens when the device is created.
> >>
> >> But now I'm even further confused then when I first reviewed it..
> If
> >>
> >> you're now supporting migration, does that mean that you're relying
> on
> >>
> >> the daemon to emulate the device?
> >>
> >>
> > Let me try to clarify this. Nothing has changed since the last patch
> except
> > for what's in the notes, i.e. migration support. The device I'm
> adding is a
> > reader. The reader is just a pipe between smart cards and the guest
> operating
> > system. The smart card logic does live outside of this device, and
> is available
> > in the cac_card sources at
> http://cgit.freedesktop.org/~alon/cac_card/ (all of
> > this is in docs/usb_ccid.txt).
> >
> > So when I speak of vscclient, I'm talking of an application that
> emulates a smart
> > card and initiates a tcp connection to qemu that connects to the
> usb-ccid device.
> > vscclient is also in the cac_card sources.
> >
>
> Okay, let me be clear. We shouldn't be doing device emulation outside
>
> of QEMU's source tree--at least, not in this type of context.
> External
> devices present a great deal of challenges and we shouldn't just
> approach it in an ad-hoc fashion.
There are two devices:
smart card reader, aka CCID device - emulated inside qemu. Submitted.
smart card - emulated outside of qemu. Fully available, open source separate project.
The idea here is to allow a remote device to be accessed from the guest. The
remote device is not running necessarily on the qemu host, so there has
to be a network connection, which implies some remote client. The only thing
that is changeable is where the card is emulated - at the client side or at qemu
side. I understand you favor qemu. But really this is not that much of a change
as you imply, and there is a good reason for having it on the client side, namely
latency of talking to the real card reader. Even if it was local to qemu, it would
still have to wait for responses from the network, so I don't see how it would be
less fragile.
I don't think the device right now is done ad-hoc, but you are welcome
to comment on anything specific (it is up for review).
(sorry for repeating myself, I guess what follows is the main point): The CCID device is a standard USB
class device, some of the USB events are handled without access to the network, and some
result in a write to the chardev (==network), which is recorded, and when a read from
the chardev happens some resulting USB activity happens. It is not yet without errors, but
it is stable, passes migration, and works most of the time. The only exception are occasional short
packets that I am still investigating, and hope won't prevent a review of the current status.
>
> I'm not opposed to passthrough although I'd prefer QEMU to talk to the
>
passthrough I'm familiar with are all on the same host QEMU is running on,
that goes for pci and usb passthrough (afaik those are the only ones).
> device directly instead of going through a daemon.
>
> There's a lot of delicate integration between QEMU and a device and if
> a
> device lives outside of QEMU, it makes it extremely difficult for us
> to
> influence changes to that device to support QEMU new features.
>
> > Regarding the method of reconnection: You are absolutely right that
> if I have qemu
> > connect to the remote instead of the other way around then I remove
> the need to inform
> > vscclient of the new address. But the way it stands requires the
> client to know the
> > address of the destination qemu. I have to inform it somehow. You
> are saying that
> > devices shouldn't know this information? ok, that's why I talked
> about monitor commands.
> > I come from the world of spice - in spice we use monitor commands
> for this.
>
> And none of that is upstream.
>
You only replied to the last part. What is your suggested fix for this case:
1. qemu -chardev socket,server,host=0.0.0.0,port=2001,id=foo,nowait -device virtioserial-port,chardev=foo
2. app X connects to 2001 from clienthost
3. migrate to otherhost running on otherport
otherhost$ qemu.. <same commandline, 2001 replaced with otherport>
4. X is left hanging
I realize it seems a contrived example, but I imagine the socket,server option is actually used like this, otherwise
what is it there for?
> Regards,
>
> Anthony Liguori
>
> > I could
> > change this to have qemu connect to vscclient, but I don't see the
> logic in general -
> > sometimes you do want to have a chardev that is listening (the fact
> that it is implemented
> > suggests someone found it useful), if you then migrate you have the
> same problem I'm
> > solving.
> >
> >
> >> Regards,
> >>
> >> Anthony Liguori
> >>
> >>
> >>> Alon Levy (2):
> >>> usb-ccid: add CCID device. add configure option.
> >>> usb-ccid: add CCID device (device itself)
> >>>
> >>> Makefile.objs | 1 +
> >>> configure | 12 +
> >>> docs/usb-ccid.txt | 115 +++++
> >>> hw/usb-ccid.c | 1376
> >>>
> >> ++++++++++++++++++++++++++++++++++++++++++++++++++++
> >>
> >>> hw/vscard_common.h | 131 +++++
> >>> 5 files changed, 1635 insertions(+), 0 deletions(-)
> >>> create mode 100644 docs/usb-ccid.txt
> >>> create mode 100644 hw/usb-ccid.c
> >>> create mode 100644 hw/vscard_common.h
> >>>
> >>>
> >>>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] [PATCH 0/2] usb-ccid device (v2)
2010-10-12 16:43 ` [Qemu-devel] [PATCH 0/2] usb-ccid device (v2) Alon Levy
@ 2010-10-12 16:49 ` Anthony Liguori
2010-10-12 17:09 ` Alon Levy
0 siblings, 1 reply; 14+ messages in thread
From: Anthony Liguori @ 2010-10-12 16:49 UTC (permalink / raw)
To: Alon Levy; +Cc: qemu-devel
On 10/12/2010 11:43 AM, Alon Levy wrote:
> ----- "Anthony Liguori"<anthony@codemonkey.ws> wrote:
>
>
>> On 10/12/2010 11:03 AM, Alon Levy wrote:
>>
>>> ----- "Anthony Liguori"<anthony@codemonkey.ws> wrote:
>>>
>>>
>>>
>>>> On 10/12/2010 07:58 AM, Alon Levy wrote:
>>>>
>>>>
>>>>> This patch adds a new device, it is described in full in the
>>>>>
>> second
>>
>>>>>
>>>>>
>>>> patch
>>>>
>>>>
>>>>> intro and also in the documentation in docs. In brief it provides
>>>>>
>> a
>>
>>>>>
>>>>>
>>>> standard
>>>>
>>>>
>>>>> smart card reader device.
>>>>>
>>>>> The first patch is the configure change and docs.
>>>>> The second patch contains the actual device, I couldn't figure out
>>>>>
>> a
>>
>>>>>
>>>>>
>>>> good
>>>>
>>>>
>>>>> way to split it to ease review.
>>>>>
>>>>> v2 changed:
>>>>> * all QSIMPLEQ turned into fixed sized rings
>>>>> * all allocated buffers turned into fixed size buffers
>>>>> * added migration support
>>>>> * added a message to tell client qemu has migrated to ip:port
>>>>> * for lack of monitor commands ip:port are 0:0, which causes
>>>>>
>> the
>>
>>>>>
>>>>>
>>>> updated
>>>>
>>>>
>>>>> vscclient to connect to one port higher on the same host.
>>>>>
>> will
>>
>>>>>
>>>>>
>>>> add monitor
>>>>
>>>>
>>>>> commands in a separate patch. tested with current setup.
>>>>>
>>>>>
>>>>>
>>>> This is way too much magic to live within a device. Devices
>>>>
>> manage
>>
>>>> reconnecting themselves during migration. When you create the
>>>> destination qemu instance, you specify what to connect to.
>>>>
>>>> IOW,
>>>>
>>>> On the source:
>>>>
>>>> qemu -chardev tcp:localhost:1025,id=foo -usbdevice
>>>>
>> ccid,chardev=foo
>>
>>>> ...
>>>>
>>>> On the destination:
>>>>
>>>> qemu -chardev tcp:localhost:1026,id=foo -usbdevice
>>>>
>> ccid,chardev=foo
>>
>>>> -incoming tcp:0.0.0.0:1024 ...
>>>>
>>>> A connection happens when the device is created.
>>>>
>>>> But now I'm even further confused then when I first reviewed it..
>>>>
>> If
>>
>>>> you're now supporting migration, does that mean that you're relying
>>>>
>> on
>>
>>>> the daemon to emulate the device?
>>>>
>>>>
>>>>
>>> Let me try to clarify this. Nothing has changed since the last patch
>>>
>> except
>>
>>> for what's in the notes, i.e. migration support. The device I'm
>>>
>> adding is a
>>
>>> reader. The reader is just a pipe between smart cards and the guest
>>>
>> operating
>>
>>> system. The smart card logic does live outside of this device, and
>>>
>> is available
>>
>>> in the cac_card sources at
>>>
>> http://cgit.freedesktop.org/~alon/cac_card/ (all of
>>
>>> this is in docs/usb_ccid.txt).
>>>
>>> So when I speak of vscclient, I'm talking of an application that
>>>
>> emulates a smart
>>
>>> card and initiates a tcp connection to qemu that connects to the
>>>
>> usb-ccid device.
>>
>>> vscclient is also in the cac_card sources.
>>>
>>>
>> Okay, let me be clear. We shouldn't be doing device emulation outside
>>
>> of QEMU's source tree--at least, not in this type of context.
>> External
>> devices present a great deal of challenges and we shouldn't just
>> approach it in an ad-hoc fashion.
>>
> There are two devices:
> smart card reader, aka CCID device - emulated inside qemu. Submitted.
> smart card - emulated outside of qemu. Fully available, open source separate project.
>
And how does the smart card state get migrated during migration? How do
you keep it synced with QEMU?
I don't understand the use-case behind this. Is this so that a local
physical smart card can be passed through to a guest from a Spice client
and when migration happens, the QEMU instance connects back to the Spice
client? So the device is never actually migrated?
Regards,
Anthony Liguori
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] [PATCH 0/2] usb-ccid device (v2)
2010-10-12 16:49 ` Anthony Liguori
@ 2010-10-12 17:09 ` Alon Levy
2010-10-12 18:23 ` Anthony Liguori
0 siblings, 1 reply; 14+ messages in thread
From: Alon Levy @ 2010-10-12 17:09 UTC (permalink / raw)
To: Anthony Liguori; +Cc: qemu-devel
----- "Anthony Liguori" <anthony@codemonkey.ws> wrote:
> On 10/12/2010 11:43 AM, Alon Levy wrote:
> > ----- "Anthony Liguori"<anthony@codemonkey.ws> wrote:
> >
> >
> >> On 10/12/2010 11:03 AM, Alon Levy wrote:
> >>
> >>> ----- "Anthony Liguori"<anthony@codemonkey.ws> wrote:
> >>>
> >>>
> >>>
> >>>> On 10/12/2010 07:58 AM, Alon Levy wrote:
> >>>>
> >>>>
> >>>>> This patch adds a new device, it is described in full in the
> >>>>>
> >> second
> >>
> >>>>>
> >>>>>
> >>>> patch
> >>>>
> >>>>
> >>>>> intro and also in the documentation in docs. In brief it
> provides
> >>>>>
> >> a
> >>
> >>>>>
> >>>>>
> >>>> standard
> >>>>
> >>>>
> >>>>> smart card reader device.
> >>>>>
> >>>>> The first patch is the configure change and docs.
> >>>>> The second patch contains the actual device, I couldn't figure
> out
> >>>>>
> >> a
> >>
> >>>>>
> >>>>>
> >>>> good
> >>>>
> >>>>
> >>>>> way to split it to ease review.
> >>>>>
> >>>>> v2 changed:
> >>>>> * all QSIMPLEQ turned into fixed sized rings
> >>>>> * all allocated buffers turned into fixed size buffers
> >>>>> * added migration support
> >>>>> * added a message to tell client qemu has migrated to
> ip:port
> >>>>> * for lack of monitor commands ip:port are 0:0, which
> causes
> >>>>>
> >> the
> >>
> >>>>>
> >>>>>
> >>>> updated
> >>>>
> >>>>
> >>>>> vscclient to connect to one port higher on the same host.
> >>>>>
> >> will
> >>
> >>>>>
> >>>>>
> >>>> add monitor
> >>>>
> >>>>
> >>>>> commands in a separate patch. tested with current setup.
> >>>>>
> >>>>>
> >>>>>
> >>>> This is way too much magic to live within a device. Devices
> >>>>
> >> manage
> >>
> >>>> reconnecting themselves during migration. When you create the
> >>>> destination qemu instance, you specify what to connect to.
> >>>>
> >>>> IOW,
> >>>>
> >>>> On the source:
> >>>>
> >>>> qemu -chardev tcp:localhost:1025,id=foo -usbdevice
> >>>>
> >> ccid,chardev=foo
> >>
> >>>> ...
> >>>>
> >>>> On the destination:
> >>>>
> >>>> qemu -chardev tcp:localhost:1026,id=foo -usbdevice
> >>>>
> >> ccid,chardev=foo
> >>
> >>>> -incoming tcp:0.0.0.0:1024 ...
> >>>>
> >>>> A connection happens when the device is created.
> >>>>
> >>>> But now I'm even further confused then when I first reviewed
> it..
> >>>>
> >> If
> >>
> >>>> you're now supporting migration, does that mean that you're
> relying
> >>>>
> >> on
> >>
> >>>> the daemon to emulate the device?
> >>>>
> >>>>
> >>>>
> >>> Let me try to clarify this. Nothing has changed since the last
> patch
> >>>
> >> except
> >>
> >>> for what's in the notes, i.e. migration support. The device I'm
> >>>
> >> adding is a
> >>
> >>> reader. The reader is just a pipe between smart cards and the
> guest
> >>>
> >> operating
> >>
> >>> system. The smart card logic does live outside of this device,
> and
> >>>
> >> is available
> >>
> >>> in the cac_card sources at
> >>>
> >> http://cgit.freedesktop.org/~alon/cac_card/ (all of
> >>
> >>> this is in docs/usb_ccid.txt).
> >>>
> >>> So when I speak of vscclient, I'm talking of an application that
> >>>
> >> emulates a smart
> >>
> >>> card and initiates a tcp connection to qemu that connects to the
> >>>
> >> usb-ccid device.
> >>
> >>> vscclient is also in the cac_card sources.
> >>>
> >>>
> >> Okay, let me be clear. We shouldn't be doing device emulation
> outside
> >>
> >> of QEMU's source tree--at least, not in this type of context.
> >> External
> >> devices present a great deal of challenges and we shouldn't just
> >> approach it in an ad-hoc fashion.
> >>
> > There are two devices:
> > smart card reader, aka CCID device - emulated inside qemu.
> Submitted.
> > smart card - emulated outside of qemu. Fully available, open
> source separate project.
> >
>
> And how does the smart card state get migrated during migration? How
> do
> you keep it synced with QEMU?
The smart card is not being migrated. It is running on the client machine,
which is not being migrated/shutdown (same as vncviewer isn't migrated).
>
> I don't understand the use-case behind this. Is this so that a local
>
> physical smart card can be passed through to a guest from a Spice
> client
> and when migration happens, the QEMU instance connects back to the
> Spice
> client? So the device is never actually migrated?
>
The *smart card* is never migrated. The ccid device is. Here is the scenario:
Host A: qemu_a
qemu_a: guest
Host B: vscclient
- physical reader
Host C: qemu_b -incoming ..
yes, we will use this for SPICE, but this is submitted
to qemu on the hopes and with testing ensuring it is perfectly usable as is
without using SPICE, otherwise I wouldn't have sent it upstream.
non-SPICE usage:
1. user on B runs vscclient (and presumably the user has some connection to the guest to use the smartcard device, i.e. vnc/ssh/spice, but that's not relevant).
2. vscclient connects via tcp to qemu_a.
3. qemu_a starts migrating to qemu_b.
(qemu_b is alive at this point, can receive incoming tcp connections on chardev - otherwise a migration fails immediately anyway)
4. pre_load for usb-ccid sends a Reconnect message
5. vscclient gets the Reconnect message, closes socket to qemu_a, opens socket to qemu_b
6. from guest pov nothing happened (no device detach/attach).
I have to stress that the main problem the migration intends to solve is to avoid a detach/attach in the guest. Actual
operations on the smartcard could possibly fail as a result of the migration, and it would not be a real problem (i.e.
we could live without, but we can't leave with a lock of the guest screen as a result of a migration). Which is why I
consider the current code good enough. It is certainly not perfect (short packet issue), or tested enough.
The SPICE usage scenario is basically the same, just replace vscclient with spicec, and
we don't need the Reconnect message since SPICE takes care of this for us (we just get
a channel detach/attach event if we care).
1. user on B runs spicec
2. spicec connects to qemu via spice channel, smart card channel connects to usb-ccid device via spicevmc chardev (so it doesn't care it's spice or not).
3. qemu_a migrates
4. spicec disconnects from qemu_a and connects to qemu_b
5. from guest os pov nothing happens on the ccid usb device.
> Regards,
>
> Anthony Liguori
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] [PATCH 0/2] usb-ccid device (v2)
2010-10-12 17:09 ` Alon Levy
@ 2010-10-12 18:23 ` Anthony Liguori
2010-10-13 11:54 ` Alon Levy
0 siblings, 1 reply; 14+ messages in thread
From: Anthony Liguori @ 2010-10-12 18:23 UTC (permalink / raw)
To: Alon Levy; +Cc: qemu-devel
On 10/12/2010 12:09 PM, Alon Levy wrote:
> The smart card is not being migrated. It is running on the client machine,
> which is not being migrated/shutdown (same as vncviewer isn't migrated).
>
>
Ok, let's look at this compared to another similar use-case: USB
passthrough of a webcam device that's remoted using USB over IP.
In this model, you have a USB bus that's modelled as a bus and a
device. Within the USB bus, you have additional devices. These are all
qdev devices and they may be emulated or they may be implemented using
passthrough. While we don't do it today, USB over IP would be just
another form of passthrough.
Migration is a rather interesting challenge in this model. You've got a
mix of client state and server state on the USB over IP connection. You
could marshal up the client state and as long as you reconnected to the
same server on the destination, I guess it would be okay.
I think the problem with your current implementation is that you've
completed skipped the bus modelling and you're also using the Device
over IP connection to implement device emulation.
What I would suggest is that you model the bus/device relationship via
qdev and move the Smart Card emulation into QEMU. I would also suggest
adding proper passthrough support in QEMU. CCID over IP is a reasonable
thing to have but I think you've got way too much outside of QEMU right
now such that long term maintenance is going to be exceedingly difficult.
Regards,
Anthony Liguori
>> I don't understand the use-case behind this. Is this so that a local
>>
>> physical smart card can be passed through to a guest from a Spice
>> client
>> and when migration happens, the QEMU instance connects back to the
>> Spice
>> client? So the device is never actually migrated?
>>
>>
> The *smart card* is never migrated. The ccid device is. Here is the scenario:
>
> Host A: qemu_a
> qemu_a: guest
>
> Host B: vscclient
> - physical reader
>
> Host C: qemu_b -incoming ..
>
> yes, we will use this for SPICE, but this is submitted
> to qemu on the hopes and with testing ensuring it is perfectly usable as is
> without using SPICE, otherwise I wouldn't have sent it upstream.
>
> non-SPICE usage:
>
> 1. user on B runs vscclient (and presumably the user has some connection to the guest to use the smartcard device, i.e. vnc/ssh/spice, but that's not relevant).
> 2. vscclient connects via tcp to qemu_a.
> 3. qemu_a starts migrating to qemu_b.
> (qemu_b is alive at this point, can receive incoming tcp connections on chardev - otherwise a migration fails immediately anyway)
> 4. pre_load for usb-ccid sends a Reconnect message
> 5. vscclient gets the Reconnect message, closes socket to qemu_a, opens socket to qemu_b
> 6. from guest pov nothing happened (no device detach/attach).
>
> I have to stress that the main problem the migration intends to solve is to avoid a detach/attach in the guest. Actual
> operations on the smartcard could possibly fail as a result of the migration, and it would not be a real problem (i.e.
> we could live without, but we can't leave with a lock of the guest screen as a result of a migration). Which is why I
> consider the current code good enough. It is certainly not perfect (short packet issue), or tested enough.
>
> The SPICE usage scenario is basically the same, just replace vscclient with spicec, and
> we don't need the Reconnect message since SPICE takes care of this for us (we just get
> a channel detach/attach event if we care).
> 1. user on B runs spicec
> 2. spicec connects to qemu via spice channel, smart card channel connects to usb-ccid device via spicevmc chardev (so it doesn't care it's spice or not).
> 3. qemu_a migrates
> 4. spicec disconnects from qemu_a and connects to qemu_b
> 5. from guest os pov nothing happens on the ccid usb device.
>
>
>> Regards,
>>
>> Anthony Liguori
>>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] [PATCH 0/2] usb-ccid device (v2)
2010-10-12 18:23 ` Anthony Liguori
@ 2010-10-13 11:54 ` Alon Levy
0 siblings, 0 replies; 14+ messages in thread
From: Alon Levy @ 2010-10-13 11:54 UTC (permalink / raw)
To: Anthony Liguori; +Cc: qemu-devel
----- "Anthony Liguori" <anthony@codemonkey.ws> wrote:
> On 10/12/2010 12:09 PM, Alon Levy wrote:
> > The smart card is not being migrated. It is running on the client
> machine,
> > which is not being migrated/shutdown (same as vncviewer isn't
> migrated).
> >
> >
>
> Ok, let's look at this compared to another similar use-case: USB
> passthrough of a webcam device that's remoted using USB over IP.
>
> In this model, you have a USB bus that's modelled as a bus and a
> device. Within the USB bus, you have additional devices. These are
> all
> qdev devices and they may be emulated or they may be implemented using
>
> passthrough. While we don't do it today, USB over IP would be just
> another form of passthrough.
>
> Migration is a rather interesting challenge in this model. You've got
> a
> mix of client state and server state on the USB over IP connection.
> You
> could marshal up the client state and as long as you reconnected to
> the
> same server on the destination, I guess it would be okay.
>
> I think the problem with your current implementation is that you've
> completed skipped the bus modelling and you're also using the Device
> over IP connection to implement device emulation.
>
> What I would suggest is that you model the bus/device relationship via
>
> qdev and move the Smart Card emulation into QEMU. I would also
> suggest
> adding proper passthrough support in QEMU. CCID over IP is a
> reasonable
> thing to have but I think you've got way too much outside of QEMU
> right
> now such that long term maintenance is going to be exceedingly
> difficult.
>
CCID over IP doesn't make any sense (It's just a specific sort of reader), but I assume you meant APDU (the smart card protocol) over IP, which is exactly what vscard_common.h protocol has (so that's already ready). I'll address the modeling of the reader device as a bus and add optional card emulation. You can regard the current implementation as exactly passthrough of APDU, that's what it does - pushes the APDU's to a remote client, and gets APDUs in return. Since I'm using an existing library for the card emulation I will make qemu link with it.
Alon
> Regards,
>
> Anthony Liguori
>
> >> I don't understand the use-case behind this. Is this so that a
> local
> >>
> >> physical smart card can be passed through to a guest from a Spice
> >> client
> >> and when migration happens, the QEMU instance connects back to the
> >> Spice
> >> client? So the device is never actually migrated?
> >>
> >>
> > The *smart card* is never migrated. The ccid device is. Here is the
> scenario:
> >
> > Host A: qemu_a
> > qemu_a: guest
> >
> > Host B: vscclient
> > - physical reader
> >
> > Host C: qemu_b -incoming ..
> >
> > yes, we will use this for SPICE, but this is submitted
> > to qemu on the hopes and with testing ensuring it is perfectly
> usable as is
> > without using SPICE, otherwise I wouldn't have sent it upstream.
> >
> > non-SPICE usage:
> >
> > 1. user on B runs vscclient (and presumably the user has some
> connection to the guest to use the smartcard device, i.e.
> vnc/ssh/spice, but that's not relevant).
> > 2. vscclient connects via tcp to qemu_a.
> > 3. qemu_a starts migrating to qemu_b.
> > (qemu_b is alive at this point, can receive incoming tcp
> connections on chardev - otherwise a migration fails immediately
> anyway)
> > 4. pre_load for usb-ccid sends a Reconnect message
> > 5. vscclient gets the Reconnect message, closes socket to qemu_a,
> opens socket to qemu_b
> > 6. from guest pov nothing happened (no device detach/attach).
> >
> > I have to stress that the main problem the migration intends to
> solve is to avoid a detach/attach in the guest. Actual
> > operations on the smartcard could possibly fail as a result of the
> migration, and it would not be a real problem (i.e.
> > we could live without, but we can't leave with a lock of the guest
> screen as a result of a migration). Which is why I
> > consider the current code good enough. It is certainly not perfect
> (short packet issue), or tested enough.
> >
> > The SPICE usage scenario is basically the same, just replace
> vscclient with spicec, and
> > we don't need the Reconnect message since SPICE takes care of this
> for us (we just get
> > a channel detach/attach event if we care).
> > 1. user on B runs spicec
> > 2. spicec connects to qemu via spice channel, smart card channel
> connects to usb-ccid device via spicevmc chardev (so it doesn't care
> it's spice or not).
> > 3. qemu_a migrates
> > 4. spicec disconnects from qemu_a and connects to qemu_b
> > 5. from guest os pov nothing happens on the ccid usb device.
> >
> >
> >> Regards,
> >>
> >> Anthony Liguori
> >>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] [PATCH 0/2] usb-ccid device (v2)
@ 2010-10-14 18:37 Robert Relyea
2010-10-14 18:52 ` Anthony Liguori
0 siblings, 1 reply; 14+ messages in thread
From: Robert Relyea @ 2010-10-14 18:37 UTC (permalink / raw)
To: qemu-devel; +Cc: Alon Levy
[-- Attachment #1.1: Type: text/plain, Size: 5097 bytes --]
Anthony Liguori wrote:
> > And how does the smart card state get migrated during migration? How
> > do you keep it synced with QEMU?
> >
> > I don't understand the use-case behind this. Is this so that a local
> > physical smart card can be passed through to a guest from a Spice
> > client and when migration happens, the QEMU instance connects back to
> > the Spice client? So the device is never actually migrated?
>
A lot of this discussion has confused me until I realized we are talking
2 different models.
My current understanding is that qemu assumes that all devices are local
to the qemu instance (that is on the host). When you migrate you want to
connect to the new hardware on the new host, not feed back to some
general client. The only exception seems to be mouse and keyboard, where
qemu depends on some external protocol (vncclient or xdesktop or the x
protocol itself) to transport the mouse and keyboard events.
Our model has been that the smart card is local to the user/client --
like the mouse and keyboard. When you migrate qemu you do not migrate
the smart card itself, since it's still physically on your client
machine (like the mouse and keyboard), and needs to be managed by the
local drivers on that client machine (which knows how to talk to the
specific smart card installed there). So the daemon stays right where
it's at and connects to the new qemu instance as it comes up. This is
where I think I was confused about your migration question. I think you
are assuming that the smart card itself connects to new hardware on the
new host, meaning the daemon itself needs to move. If that is the
semantic you are trying to present, then you are quite right, it's
ludicrous to have the external daemon as part of the emulation.
It now appears to me that qemu punts on this case, except for the
keyboard and mouse -- well maybe not punts, but simply doesn't support
any device that isn't on the host machine. If you look at the way qemu
handles the sound device, for instance. Normally you want the sound to
come out the speakers of the controlling console, not a random server
that's hosting the guest. However, straight qemu doesn't handle things
that way. The sound (if it comes out at all) comes out the server that
qemu is installed on. When you migrate qemu, the sound now comes out the
new server.
This probably isn't a problem since most of the time someone is using
the speaker, he's got the case where host == client. In that case it
makes perfect sense to put the emulator inside qemu. In the case where
we are running a hosted server service, it's highly unlikely anyone is
going to be using sound (or an attached webcam, etc.). In fact migration
for these devices are really a noop.
Smart cards are really like these devices. In fact more than a few
keyboards have built in smart card readers. The smart card model is I
want the smart card at the same location as my keyboard and mouse. I use
that set of smart cards to authenticate. The use case on machines
running with a server is that some customers have a requirement that you
need the smart card to log in and administer those machines. Those smart
cards are ones the operator carries with him, not ones that would sit on
some server farm. For their requirements, one needs a way to get back to
the local client.
As I said before, I don't think this requirement is unique. The only way
to handle it is to run code on the client machine. The devices that run
on that client are ones you don't migrate with qemu, but stay with the
client itself and reconnect to the new instance. I agree that having a
daemon for each devices will eventually become unweildy. It looks like
spice is the answer for this scenario. If you have devices other than
the mouse/keyboard/display that are located on the client == host, then
you should assume the need for spice and not use straight qemu?
In that world it makes sense to have a single protocol (passthru). It's
ok to integrate the smart card emul directly into qemu because it's
really only used either in the case where client != host, or in the case
where your server hardware has some smart card installed that is uses
for authentication. (NOTE: in this case, migrate means that the server
will loose authentication and have to authenticate with the new smart
card on the new host... I don't know how useful this really is, but I
think it's important to point out that migrate with smart cards means
something different than most devices. It means you have become a new
entity, not a continuation of the old... it's the equivalent of pulling
a smart card on a server and inserting a new one).
So if my understanding is correct, as long as you are willing to deal
with the card plug/unplug scenario on migration, it makes sense for qemu
to have passthru plus a local emulated smart card which goes directly to
local hardward. If you need to have the 'console' experience, then you
turn on spice and emulate the card in the spice client.
bob
[-- Attachment #1.2: Type: text/html, Size: 5859 bytes --]
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 6014 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] [PATCH 0/2] usb-ccid device (v2)
2010-10-14 18:37 Robert Relyea
@ 2010-10-14 18:52 ` Anthony Liguori
2010-10-14 22:03 ` Robert Relyea
0 siblings, 1 reply; 14+ messages in thread
From: Anthony Liguori @ 2010-10-14 18:52 UTC (permalink / raw)
To: Robert Relyea; +Cc: Alon Levy, qemu-devel
[-- Attachment #1: Type: text/plain, Size: 6309 bytes --]
On 10/14/2010 01:37 PM, Robert Relyea wrote:
> Anthony Liguori wrote:
>
>
>> > And how does the smart card state get migrated during migration? How
>> > do you keep it synced with QEMU?
>> >
>> > I don't understand the use-case behind this. Is this so that a local
>> > physical smart card can be passed through to a guest from a Spice
>> > client and when migration happens, the QEMU instance connects back to
>> > the Spice client? So the device is never actually migrated?
>>
> A lot of this discussion has confused me until I realized we are talking
> 2 different models.
>
> My current understanding is that qemu assumes that all devices are local
> to the qemu instance (that is on the host). When you migrate you want to
> connect to the new hardware on the new host, not feed back to some
> general client. The only exception seems to be mouse and keyboard, where
> qemu depends on some external protocol (vncclient or xdesktop or the x
> protocol itself) to transport the mouse and keyboard events.
>
> Our model has been that the smart card is local to the user/client --
> like the mouse and keyboard. When you migrate qemu you do not migrate
> the smart card itself, since it's still physically on your client
> machine (like the mouse and keyboard), and needs to be managed by the
> local drivers on that client machine (which knows how to talk to the
> specific smart card installed there). So the daemon stays right where
> it's at and connects to the new qemu instance as it comes up. This is
> where I think I was confused about your migration question. I think you
> are assuming that the smart card itself connects to new hardware on the
> new host, meaning the daemon itself needs to move. If that is the
> semantic you are trying to present, then you are quite right, it's
> ludicrous to have the external daemon as part of the emulation.
>
Remote device passthrough is just a special case of passthrough. It's
got interesting characteristics in that unlike local device passthrough,
if you preserve the connection to the remove device, migration is still
possible.
However, remote device *emulation* is the thing that I'm concerned
about. Having a device emulated outside of QEMU means that it's not
possible to participate in many of QEMU's features (like live migration,
tracing, debugging, etc.). Device creation is extremely complicated
because you have to launch the external daemon and somehow configure that.
I have no objection to remote device passthrough but I don't think
remote device emulation is right for QEMU today.
After talking to Alon in IRC, I think a better model for Spice would be
to integrate the smart card emulation into QEMU and then develop a
specific protocol for the smart card emulation to interface with the
physical smart card. This interface isn't really any different than the
network interface or the block interface in QEMU today.
Regards,
Anthony Liguori
> It now appears to me that qemu punts on this case, except for the
> keyboard and mouse -- well maybe not punts, but simply doesn't support
> any device that isn't on the host machine. If you look at the way qemu
> handles the sound device, for instance. Normally you want the sound to
> come out the speakers of the controlling console, not a random server
> that's hosting the guest. However, straight qemu doesn't handle things
> that way. The sound (if it comes out at all) comes out the server that
> qemu is installed on. When you migrate qemu, the sound now comes out the
> new server.
>
> This probably isn't a problem since most of the time someone is using
> the speaker, he's got the case where host == client. In that case it
> makes perfect sense to put the emulator inside qemu. In the case where
> we are running a hosted server service, it's highly unlikely anyone is
> going to be using sound (or an attached webcam, etc.). In fact migration
> for these devices are really a noop.
>
> Smart cards are really like these devices. In fact more than a few
> keyboards have built in smart card readers. The smart card model is I
> want the smart card at the same location as my keyboard and mouse. I use
> that set of smart cards to authenticate. The use case on machines
> running with a server is that some customers have a requirement that you
> need the smart card to log in and administer those machines. Those smart
> cards are ones the operator carries with him, not ones that would sit on
> some server farm. For their requirements, one needs a way to get back to
> the local client.
>
> As I said before, I don't think this requirement is unique. The only way
> to handle it is to run code on the client machine. The devices that run
> on that client are ones you don't migrate with qemu, but stay with the
> client itself and reconnect to the new instance. I agree that having a
> daemon for each devices will eventually become unweildy. It looks like
> spice is the answer for this scenario. If you have devices other than
> the mouse/keyboard/display that are located on the client == host, then
> you should assume the need for spice and not use straight qemu?
>
> In that world it makes sense to have a single protocol (passthru). It's
> ok to integrate the smart card emul directly into qemu because it's
> really only used either in the case where client != host, or in the case
> where your server hardware has some smart card installed that is uses
> for authentication. (NOTE: in this case, migrate means that the server
> will loose authentication and have to authenticate with the new smart
> card on the new host... I don't know how useful this really is, but I
> think it's important to point out that migrate with smart cards means
> something different than most devices. It means you have become a new
> entity, not a continuation of the old... it's the equivalent of pulling
> a smart card on a server and inserting a new one).
>
> So if my understanding is correct, as long as you are willing to deal
> with the card plug/unplug scenario on migration, it makes sense for qemu
> to have passthru plus a local emulated smart card which goes directly to
> local hardward. If you need to have the 'console' experience, then you
> turn on spice and emulate the card in the spice client.
>
> bob
>
>
>
>
>
>
>
>
[-- Attachment #2: Type: text/html, Size: 7353 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] [PATCH 0/2] usb-ccid device (v2)
2010-10-14 18:52 ` Anthony Liguori
@ 2010-10-14 22:03 ` Robert Relyea
2010-10-14 22:16 ` Anthony Liguori
0 siblings, 1 reply; 14+ messages in thread
From: Robert Relyea @ 2010-10-14 22:03 UTC (permalink / raw)
To: Anthony Liguori; +Cc: Alon Levy, qemu-devel
[-- Attachment #1.1: Type: text/plain, Size: 7503 bytes --]
On 10/14/2010 11:52 AM, Anthony Liguori wrote:
> On 10/14/2010 01:37 PM, Robert Relyea wrote:
>> Anthony Liguori wrote:
>>
>>
>>> > And how does the smart card state get migrated during migration? How
>>> > do you keep it synced with QEMU?
>>> >
>>> > I don't understand the use-case behind this. Is this so that a local
>>> > physical smart card can be passed through to a guest from a Spice
>>> > client and when migration happens, the QEMU instance connects back to
>>> > the Spice client? So the device is never actually migrated?
>>>
>> A lot of this discussion has confused me until I realized we are talking
>> 2 different models.
>>
>> My current understanding is that qemu assumes that all devices are local
>> to the qemu instance (that is on the host). When you migrate you want to
>> connect to the new hardware on the new host, not feed back to some
>> general client. The only exception seems to be mouse and keyboard, where
>> qemu depends on some external protocol (vncclient or xdesktop or the x
>> protocol itself) to transport the mouse and keyboard events.
>>
>> Our model has been that the smart card is local to the user/client --
>> like the mouse and keyboard. When you migrate qemu you do not migrate
>> the smart card itself, since it's still physically on your client
>> machine (like the mouse and keyboard), and needs to be managed by the
>> local drivers on that client machine (which knows how to talk to the
>> specific smart card installed there). So the daemon stays right where
>> it's at and connects to the new qemu instance as it comes up. This is
>> where I think I was confused about your migration question. I think you
>> are assuming that the smart card itself connects to new hardware on the
>> new host, meaning the daemon itself needs to move. If that is the
>> semantic you are trying to present, then you are quite right, it's
>> ludicrous to have the external daemon as part of the emulation.
>>
>
>
> Remote device passthrough is just a special case of passthrough. It's
> got interesting characteristics in that unlike local device
> passthrough, if you preserve the connection to the remove device,
> migration is still possible.
>
> However, remote device *emulation* is the thing that I'm concerned
> about. Having a device emulated outside of QEMU means that it's not
> possible to participate in many of QEMU's features (like live
> migration, tracing, debugging, etc.). Device creation is extremely
> complicated because you have to launch the external daemon and somehow
> configure that.
There's always some emulation going on on the client side. The client
side has the device drivers, so you are either emulating an actual
device or you are emulating the abstraction you invent. Once you have
the client side, you have to launch the external daemon anyway.
It seems to me that the best way to go is to provide the native host ==
client support like other devices and allow the passthru. If you really
need client support, just run spice (which is a single client daemon
that handles everything).
>
> I have no objection to remote device passthrough but I don't think
> remote device emulation is right for QEMU today.
Probably right for raw qemu.
>
> After talking to Alon in IRC, I think a better model for Spice would
> be to integrate the smart card emulation into QEMU and then develop a
> specific protocol for the smart card emulation to interface with the
> physical smart card. This interface isn't really any different than
> the network interface or the block interface in QEMU today.
I seems to me that a second protocol is overkill. Having 2 protocols is
a bit much to manage. We can do everything we need with the passthru. My
worry about creating any thing else is we may not have the flexibility
to handle future cards. Smart cards themselves are programmable, so the
interface for new cards are pretty dynamic.
bob
>
> Regards,
>
> Anthony Liguori
>
>> It now appears to me that qemu punts on this case, except for the
>> keyboard and mouse -- well maybe not punts, but simply doesn't support
>> any device that isn't on the host machine. If you look at the way qemu
>> handles the sound device, for instance. Normally you want the sound to
>> come out the speakers of the controlling console, not a random server
>> that's hosting the guest. However, straight qemu doesn't handle things
>> that way. The sound (if it comes out at all) comes out the server that
>> qemu is installed on. When you migrate qemu, the sound now comes out the
>> new server.
>>
>> This probably isn't a problem since most of the time someone is using
>> the speaker, he's got the case where host == client. In that case it
>> makes perfect sense to put the emulator inside qemu. In the case where
>> we are running a hosted server service, it's highly unlikely anyone is
>> going to be using sound (or an attached webcam, etc.). In fact migration
>> for these devices are really a noop.
>>
>> Smart cards are really like these devices. In fact more than a few
>> keyboards have built in smart card readers. The smart card model is I
>> want the smart card at the same location as my keyboard and mouse. I use
>> that set of smart cards to authenticate. The use case on machines
>> running with a server is that some customers have a requirement that you
>> need the smart card to log in and administer those machines. Those smart
>> cards are ones the operator carries with him, not ones that would sit on
>> some server farm. For their requirements, one needs a way to get back to
>> the local client.
>>
>> As I said before, I don't think this requirement is unique. The only way
>> to handle it is to run code on the client machine. The devices that run
>> on that client are ones you don't migrate with qemu, but stay with the
>> client itself and reconnect to the new instance. I agree that having a
>> daemon for each devices will eventually become unweildy. It looks like
>> spice is the answer for this scenario. If you have devices other than
>> the mouse/keyboard/display that are located on the client == host, then
>> you should assume the need for spice and not use straight qemu?
>>
>> In that world it makes sense to have a single protocol (passthru). It's
>> ok to integrate the smart card emul directly into qemu because it's
>> really only used either in the case where client != host, or in the case
>> where your server hardware has some smart card installed that is uses
>> for authentication. (NOTE: in this case, migrate means that the server
>> will loose authentication and have to authenticate with the new smart
>> card on the new host... I don't know how useful this really is, but I
>> think it's important to point out that migrate with smart cards means
>> something different than most devices. It means you have become a new
>> entity, not a continuation of the old... it's the equivalent of pulling
>> a smart card on a server and inserting a new one).
>>
>> So if my understanding is correct, as long as you are willing to deal
>> with the card plug/unplug scenario on migration, it makes sense for qemu
>> to have passthru plus a local emulated smart card which goes directly to
>> local hardward. If you need to have the 'console' experience, then you
>> turn on spice and emulate the card in the spice client.
>>
>> bob
>>
>>
>>
>>
>>
>>
>>
>>
>
[-- Attachment #1.2: Type: text/html, Size: 8915 bytes --]
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 6014 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] [PATCH 0/2] usb-ccid device (v2)
2010-10-14 22:03 ` Robert Relyea
@ 2010-10-14 22:16 ` Anthony Liguori
2010-10-15 0:16 ` Robert Relyea
0 siblings, 1 reply; 14+ messages in thread
From: Anthony Liguori @ 2010-10-14 22:16 UTC (permalink / raw)
To: Robert Relyea; +Cc: Alon Levy, qemu-devel
[-- Attachment #1: Type: text/plain, Size: 6626 bytes --]
On 10/14/2010 05:03 PM, Robert Relyea wrote:
>> Remote device passthrough is just a special case of passthrough.
>> It's got interesting characteristics in that unlike local device
>> passthrough, if you preserve the connection to the remove device,
>> migration is still possible.
>>
>> However, remote device *emulation* is the thing that I'm concerned
>> about. Having a device emulated outside of QEMU means that it's not
>> possible to participate in many of QEMU's features (like live
>> migration, tracing, debugging, etc.). Device creation is extremely
>> complicated because you have to launch the external daemon and
>> somehow configure that.
> There's always some emulation going on on the client side. The client
> side has the device drivers, so you are either emulating an actual
> device or you are emulating the abstraction you invent. Once you have
> the client side, you have to launch the external daemon anyway.
That's not a very convincing argument.
It's pretty simple really. We don't want to split QEMU into a bunch of
different daemons that all implement device emulation in slightly
different ways. The user complexity is enormous and the ability to
manage the complexity because impossible because nothing is centralized.
> It seems to me that the best way to go is to provide the native host
> == client support like other devices and allow the passthru. If you
> really need client support, just run spice (which is a single client
> daemon that handles everything).
Let's not confuse passthrough with implementing device emulation outside
of QEMU. They are two very different things.
I think a remote passthrough protocol who's sole purpose is to allow
external device emulation is a bad idea for QEMU.
>>
>> After talking to Alon in IRC, I think a better model for Spice would
>> be to integrate the smart card emulation into QEMU and then develop a
>> specific protocol for the smart card emulation to interface with the
>> physical smart card. This interface isn't really any different than
>> the network interface or the block interface in QEMU today.
> I seems to me that a second protocol is overkill. Having 2 protocols
> is a bit much to manage. We can do everything we need with the passthru.
How is external device emulation not overkill? I don't see why two
protocols are necessary. You just need one.
> My worry about creating any thing else is we may not have the
> flexibility to handle future cards. Smart cards themselves are
> programmable, so the interface for new cards are pretty dynamic.
My worry is that we're creating an impossible situation to maintain in
the long term because device emulation is happening in 10 different
places. If there's a bug in your smart card emulation, a guest can now
break into a Spice client. Part of the advantage of keeping everything
contained in a single place (QEMU) is that we can restrict QEMU from a
security perspective via sVirt and other mechanisms. Once you split
apart device emulation, you break that security model.
Regards,
Anthony Liguori
> bob
>>
>> Regards,
>>
>> Anthony Liguori
>>
>>> It now appears to me that qemu punts on this case, except for the
>>> keyboard and mouse -- well maybe not punts, but simply doesn't support
>>> any device that isn't on the host machine. If you look at the way qemu
>>> handles the sound device, for instance. Normally you want the sound to
>>> come out the speakers of the controlling console, not a random server
>>> that's hosting the guest. However, straight qemu doesn't handle things
>>> that way. The sound (if it comes out at all) comes out the server that
>>> qemu is installed on. When you migrate qemu, the sound now comes out the
>>> new server.
>>>
>>> This probably isn't a problem since most of the time someone is using
>>> the speaker, he's got the case where host == client. In that case it
>>> makes perfect sense to put the emulator inside qemu. In the case where
>>> we are running a hosted server service, it's highly unlikely anyone is
>>> going to be using sound (or an attached webcam, etc.). In fact migration
>>> for these devices are really a noop.
>>>
>>> Smart cards are really like these devices. In fact more than a few
>>> keyboards have built in smart card readers. The smart card model is I
>>> want the smart card at the same location as my keyboard and mouse. I use
>>> that set of smart cards to authenticate. The use case on machines
>>> running with a server is that some customers have a requirement that you
>>> need the smart card to log in and administer those machines. Those smart
>>> cards are ones the operator carries with him, not ones that would sit on
>>> some server farm. For their requirements, one needs a way to get back to
>>> the local client.
>>>
>>> As I said before, I don't think this requirement is unique. The only way
>>> to handle it is to run code on the client machine. The devices that run
>>> on that client are ones you don't migrate with qemu, but stay with the
>>> client itself and reconnect to the new instance. I agree that having a
>>> daemon for each devices will eventually become unweildy. It looks like
>>> spice is the answer for this scenario. If you have devices other than
>>> the mouse/keyboard/display that are located on the client == host, then
>>> you should assume the need for spice and not use straight qemu?
>>>
>>> In that world it makes sense to have a single protocol (passthru). It's
>>> ok to integrate the smart card emul directly into qemu because it's
>>> really only used either in the case where client != host, or in the case
>>> where your server hardware has some smart card installed that is uses
>>> for authentication. (NOTE: in this case, migrate means that the server
>>> will loose authentication and have to authenticate with the new smart
>>> card on the new host... I don't know how useful this really is, but I
>>> think it's important to point out that migrate with smart cards means
>>> something different than most devices. It means you have become a new
>>> entity, not a continuation of the old... it's the equivalent of pulling
>>> a smart card on a server and inserting a new one).
>>>
>>> So if my understanding is correct, as long as you are willing to deal
>>> with the card plug/unplug scenario on migration, it makes sense for qemu
>>> to have passthru plus a local emulated smart card which goes directly to
>>> local hardward. If you need to have the 'console' experience, then you
>>> turn on spice and emulate the card in the spice client.
>>>
>>> bob
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>
>
[-- Attachment #2: Type: text/html, Size: 7546 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] [PATCH 0/2] usb-ccid device (v2)
2010-10-14 22:16 ` Anthony Liguori
@ 2010-10-15 0:16 ` Robert Relyea
0 siblings, 0 replies; 14+ messages in thread
From: Robert Relyea @ 2010-10-15 0:16 UTC (permalink / raw)
To: Anthony Liguori; +Cc: Alon Levy, qemu-devel
[-- Attachment #1.1: Type: text/plain, Size: 4928 bytes --]
On 10/14/2010 03:16 PM, Anthony Liguori wrote:
> On 10/14/2010 05:03 PM, Robert Relyea wrote:
>>> Remote device passthrough is just a special case of passthrough.
>>> It's got interesting characteristics in that unlike local device
>>> passthrough, if you preserve the connection to the remove device,
>>> migration is still possible.
>>>
>>> However, remote device *emulation* is the thing that I'm concerned
>>> about. Having a device emulated outside of QEMU means that it's not
>>> possible to participate in many of QEMU's features (like live
>>> migration, tracing, debugging, etc.). Device creation is extremely
>>> complicated because you have to launch the external daemon and
>>> somehow configure that.
>> There's always some emulation going on on the client side. The client
>> side has the device drivers, so you are either emulating an actual
>> device or you are emulating the abstraction you invent. Once you have
>> the client side, you have to launch the external daemon anyway.
>
> That's not a very convincing argument.
Neither is that;). My point is that no matter what you do, there is
*always* some sort of client emulation going on and the client is the
only one in this scenario that has access to the local drivers. This is
all moot. The only client side qemu supports is vnc/X/xdesktop. All
those devices have client side drivers that are emulating the overall
protocol.
>
> It's pretty simple really. We don't want to split QEMU into a bunch
> of different daemons that all implement device emulation in slightly
> different ways. The user complexity is enormous and the ability to
> manage the complexity because impossible because nothing is centralized.
I think you misunderstand me. In some sense I'm agreeing with you. I
agree you don't want to split QEMU into a bunch of daemons, which is why
I think you handle the smart card remotely only with spice. Currently
QEMU doesn't have the infrastructure to handle lots of different client
devices (pretty much only if there is some preexisting client like vnc
that handles those things).
In some sense we seem to be talking cross purposes here. I agree that
QEMU isn't the right place to handle client side devices. It's clearly
not in the QEMU model, so it makes sense NOT to emulate on the client
side for QEMU...
>
>> It seems to me that the best way to go is to provide the native host
>> == client support like other devices and allow the passthru. If you
>> really need client support, just run spice (which is a single client
>> daemon that handles everything).
>
> Let's not confuse passthrough with implementing device emulation
> outside of QEMU. They are two very different things.
>
> I think a remote passthrough protocol who's sole purpose is to allow
> external device emulation is a bad idea for QEMU.
The passthru is passthru. I'm not sure what you mean here.... I'm
presuming the way forward is to have passthru and qemu implementing a
local smart card emulation. I'm fine with just passthru and local
emulation to a local smart card.
>
>>>
>>> After talking to Alon in IRC, I think a better model for Spice would
>>> be to integrate the smart card emulation into QEMU and then develop
>>> a specific protocol for the smart card emulation to interface with
>>> the physical smart card. This interface isn't really any different
>>> than the network interface or the block interface in QEMU today.
>> I seems to me that a second protocol is overkill. Having 2 protocols
>> is a bit much to manage. We can do everything we need with the passthru.
>
> How is external device emulation not overkill? I don't see why two
> protocols are necessary. You just need one.
If you have one for passthru and one for emulated cards, that's two
protocols.
>
>> My worry about creating any thing else is we may not have the
>> flexibility to handle future cards. Smart cards themselves are
>> programmable, so the interface for new cards are pretty dynamic.
>
> My worry is that we're creating an impossible situation to maintain in
> the long term because device emulation is happening in 10 different
> places. If there's a bug in your smart card emulation, a guest can
> now break into a Spice client. Part of the advantage of keeping
> everything contained in a single place (QEMU) is that we can restrict
> QEMU from a security perspective via sVirt and other mechanisms. Once
> you split apart device emulation, you break that security model.
That's true whether I'm emulating on qemu or not. If there is a bug in
the emulation code, you can break out. If there is a bug in the client
side driver, you can break out. The risk is exactly the same.
But again, this is academic, I'm not advocating doing this in qemu.
Clearly there needs to be more work before we can even talk about qemu
client side devices where client != host.
bob
[-- Attachment #1.2: Type: text/html, Size: 6146 bytes --]
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 6014 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
[parent not found: <1045788737.212361286898758903.JavaMail.root@zmail06.collab.prod.int.phx2.redhat.com>]
* Re: [Qemu-devel] [PATCH 0/2] usb-ccid device (v2)
[not found] <1045788737.212361286898758903.JavaMail.root@zmail06.collab.prod.int.phx2.redhat.com>
@ 2010-10-12 16:03 ` Alon Levy
2010-10-12 16:21 ` Anthony Liguori
0 siblings, 1 reply; 14+ messages in thread
From: Alon Levy @ 2010-10-12 16:03 UTC (permalink / raw)
To: Anthony Liguori; +Cc: qemu-devel
----- "Anthony Liguori" <anthony@codemonkey.ws> wrote:
> On 10/12/2010 07:58 AM, Alon Levy wrote:
> > This patch adds a new device, it is described in full in the second
> patch
> > intro and also in the documentation in docs. In brief it provides a
> standard
> > smart card reader device.
> >
> > The first patch is the configure change and docs.
> > The second patch contains the actual device, I couldn't figure out a
> good
> > way to split it to ease review.
> >
> > v2 changed:
> > * all QSIMPLEQ turned into fixed sized rings
> > * all allocated buffers turned into fixed size buffers
> > * added migration support
> > * added a message to tell client qemu has migrated to ip:port
> > * for lack of monitor commands ip:port are 0:0, which causes the
> updated
> > vscclient to connect to one port higher on the same host. will
> add monitor
> > commands in a separate patch. tested with current setup.
> >
>
> This is way too much magic to live within a device. Devices manage
> reconnecting themselves during migration. When you create the
> destination qemu instance, you specify what to connect to.
>
> IOW,
>
> On the source:
>
> qemu -chardev tcp:localhost:1025,id=foo -usbdevice ccid,chardev=foo
> ...
>
> On the destination:
>
> qemu -chardev tcp:localhost:1026,id=foo -usbdevice ccid,chardev=foo
> -incoming tcp:0.0.0.0:1024 ...
>
> A connection happens when the device is created.
>
> But now I'm even further confused then when I first reviewed it.. If
>
> you're now supporting migration, does that mean that you're relying on
>
> the daemon to emulate the device?
>
Let me try to clarify this. Nothing has changed since the last patch except
for what's in the notes, i.e. migration support. The device I'm adding is a
reader. The reader is just a pipe between smart cards and the guest operating
system. The smart card logic does live outside of this device, and is available
in the cac_card sources at http://cgit.freedesktop.org/~alon/cac_card/ (all of
this is in docs/usb_ccid.txt).
So when I speak of vscclient, I'm talking of an application that emulates a smart
card and initiates a tcp connection to qemu that connects to the usb-ccid device.
vscclient is also in the cac_card sources.
Regarding the method of reconnection: You are absolutely right that if I have qemu
connect to the remote instead of the other way around then I remove the need to inform
vscclient of the new address. But the way it stands requires the client to know the
address of the destination qemu. I have to inform it somehow. You are saying that
devices shouldn't know this information? ok, that's why I talked about monitor commands.
I come from the world of spice - in spice we use monitor commands for this. I could
change this to have qemu connect to vscclient, but I don't see the logic in general -
sometimes you do want to have a chardev that is listening (the fact that it is implemented
suggests someone found it useful), if you then migrate you have the same problem I'm
solving.
> Regards,
>
> Anthony Liguori
>
> > Alon Levy (2):
> > usb-ccid: add CCID device. add configure option.
> > usb-ccid: add CCID device (device itself)
> >
> > Makefile.objs | 1 +
> > configure | 12 +
> > docs/usb-ccid.txt | 115 +++++
> > hw/usb-ccid.c | 1376
> ++++++++++++++++++++++++++++++++++++++++++++++++++++
> > hw/vscard_common.h | 131 +++++
> > 5 files changed, 1635 insertions(+), 0 deletions(-)
> > create mode 100644 docs/usb-ccid.txt
> > create mode 100644 hw/usb-ccid.c
> > create mode 100644 hw/vscard_common.h
> >
> >
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] [PATCH 0/2] usb-ccid device (v2)
2010-10-12 16:03 ` Alon Levy
@ 2010-10-12 16:21 ` Anthony Liguori
0 siblings, 0 replies; 14+ messages in thread
From: Anthony Liguori @ 2010-10-12 16:21 UTC (permalink / raw)
To: Alon Levy; +Cc: qemu-devel
On 10/12/2010 11:03 AM, Alon Levy wrote:
> ----- "Anthony Liguori"<anthony@codemonkey.ws> wrote:
>
>
>> On 10/12/2010 07:58 AM, Alon Levy wrote:
>>
>>> This patch adds a new device, it is described in full in the second
>>>
>> patch
>>
>>> intro and also in the documentation in docs. In brief it provides a
>>>
>> standard
>>
>>> smart card reader device.
>>>
>>> The first patch is the configure change and docs.
>>> The second patch contains the actual device, I couldn't figure out a
>>>
>> good
>>
>>> way to split it to ease review.
>>>
>>> v2 changed:
>>> * all QSIMPLEQ turned into fixed sized rings
>>> * all allocated buffers turned into fixed size buffers
>>> * added migration support
>>> * added a message to tell client qemu has migrated to ip:port
>>> * for lack of monitor commands ip:port are 0:0, which causes the
>>>
>> updated
>>
>>> vscclient to connect to one port higher on the same host. will
>>>
>> add monitor
>>
>>> commands in a separate patch. tested with current setup.
>>>
>>>
>> This is way too much magic to live within a device. Devices manage
>> reconnecting themselves during migration. When you create the
>> destination qemu instance, you specify what to connect to.
>>
>> IOW,
>>
>> On the source:
>>
>> qemu -chardev tcp:localhost:1025,id=foo -usbdevice ccid,chardev=foo
>> ...
>>
>> On the destination:
>>
>> qemu -chardev tcp:localhost:1026,id=foo -usbdevice ccid,chardev=foo
>> -incoming tcp:0.0.0.0:1024 ...
>>
>> A connection happens when the device is created.
>>
>> But now I'm even further confused then when I first reviewed it.. If
>>
>> you're now supporting migration, does that mean that you're relying on
>>
>> the daemon to emulate the device?
>>
>>
> Let me try to clarify this. Nothing has changed since the last patch except
> for what's in the notes, i.e. migration support. The device I'm adding is a
> reader. The reader is just a pipe between smart cards and the guest operating
> system. The smart card logic does live outside of this device, and is available
> in the cac_card sources at http://cgit.freedesktop.org/~alon/cac_card/ (all of
> this is in docs/usb_ccid.txt).
>
> So when I speak of vscclient, I'm talking of an application that emulates a smart
> card and initiates a tcp connection to qemu that connects to the usb-ccid device.
> vscclient is also in the cac_card sources.
>
Okay, let me be clear. We shouldn't be doing device emulation outside
of QEMU's source tree--at least, not in this type of context. External
devices present a great deal of challenges and we shouldn't just
approach it in an ad-hoc fashion.
I'm not opposed to passthrough although I'd prefer QEMU to talk to the
device directly instead of going through a daemon.
There's a lot of delicate integration between QEMU and a device and if a
device lives outside of QEMU, it makes it extremely difficult for us to
influence changes to that device to support QEMU new features.
> Regarding the method of reconnection: You are absolutely right that if I have qemu
> connect to the remote instead of the other way around then I remove the need to inform
> vscclient of the new address. But the way it stands requires the client to know the
> address of the destination qemu. I have to inform it somehow. You are saying that
> devices shouldn't know this information? ok, that's why I talked about monitor commands.
> I come from the world of spice - in spice we use monitor commands for this.
And none of that is upstream.
Regards,
Anthony Liguori
> I could
> change this to have qemu connect to vscclient, but I don't see the logic in general -
> sometimes you do want to have a chardev that is listening (the fact that it is implemented
> suggests someone found it useful), if you then migrate you have the same problem I'm
> solving.
>
>
>> Regards,
>>
>> Anthony Liguori
>>
>>
>>> Alon Levy (2):
>>> usb-ccid: add CCID device. add configure option.
>>> usb-ccid: add CCID device (device itself)
>>>
>>> Makefile.objs | 1 +
>>> configure | 12 +
>>> docs/usb-ccid.txt | 115 +++++
>>> hw/usb-ccid.c | 1376
>>>
>> ++++++++++++++++++++++++++++++++++++++++++++++++++++
>>
>>> hw/vscard_common.h | 131 +++++
>>> 5 files changed, 1635 insertions(+), 0 deletions(-)
>>> create mode 100644 docs/usb-ccid.txt
>>> create mode 100644 hw/usb-ccid.c
>>> create mode 100644 hw/vscard_common.h
>>>
>>>
>>>
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Qemu-devel] [PATCH 0/2] usb-ccid device (v2)
@ 2010-10-12 12:58 Alon Levy
2010-10-12 13:24 ` Anthony Liguori
0 siblings, 1 reply; 14+ messages in thread
From: Alon Levy @ 2010-10-12 12:58 UTC (permalink / raw)
To: qemu-devel
This patch adds a new device, it is described in full in the second patch
intro and also in the documentation in docs. In brief it provides a standard
smart card reader device.
The first patch is the configure change and docs.
The second patch contains the actual device, I couldn't figure out a good
way to split it to ease review.
v2 changed:
* all QSIMPLEQ turned into fixed sized rings
* all allocated buffers turned into fixed size buffers
* added migration support
* added a message to tell client qemu has migrated to ip:port
* for lack of monitor commands ip:port are 0:0, which causes the updated
vscclient to connect to one port higher on the same host. will add monitor
commands in a separate patch. tested with current setup.
Alon Levy (2):
usb-ccid: add CCID device. add configure option.
usb-ccid: add CCID device (device itself)
Makefile.objs | 1 +
configure | 12 +
docs/usb-ccid.txt | 115 +++++
hw/usb-ccid.c | 1376 ++++++++++++++++++++++++++++++++++++++++++++++++++++
hw/vscard_common.h | 131 +++++
5 files changed, 1635 insertions(+), 0 deletions(-)
create mode 100644 docs/usb-ccid.txt
create mode 100644 hw/usb-ccid.c
create mode 100644 hw/vscard_common.h
--
1.7.3.1
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [Qemu-devel] [PATCH 0/2] usb-ccid device (v2)
2010-10-12 12:58 Alon Levy
@ 2010-10-12 13:24 ` Anthony Liguori
0 siblings, 0 replies; 14+ messages in thread
From: Anthony Liguori @ 2010-10-12 13:24 UTC (permalink / raw)
To: Alon Levy; +Cc: qemu-devel
On 10/12/2010 07:58 AM, Alon Levy wrote:
> This patch adds a new device, it is described in full in the second patch
> intro and also in the documentation in docs. In brief it provides a standard
> smart card reader device.
>
> The first patch is the configure change and docs.
> The second patch contains the actual device, I couldn't figure out a good
> way to split it to ease review.
>
> v2 changed:
> * all QSIMPLEQ turned into fixed sized rings
> * all allocated buffers turned into fixed size buffers
> * added migration support
> * added a message to tell client qemu has migrated to ip:port
> * for lack of monitor commands ip:port are 0:0, which causes the updated
> vscclient to connect to one port higher on the same host. will add monitor
> commands in a separate patch. tested with current setup.
>
This is way too much magic to live within a device. Devices manage
reconnecting themselves during migration. When you create the
destination qemu instance, you specify what to connect to.
IOW,
On the source:
qemu -chardev tcp:localhost:1025,id=foo -usbdevice ccid,chardev=foo ...
On the destination:
qemu -chardev tcp:localhost:1026,id=foo -usbdevice ccid,chardev=foo
-incoming tcp:0.0.0.0:1024 ...
A connection happens when the device is created.
But now I'm even further confused then when I first reviewed it.. If
you're now supporting migration, does that mean that you're relying on
the daemon to emulate the device?
Regards,
Anthony Liguori
> Alon Levy (2):
> usb-ccid: add CCID device. add configure option.
> usb-ccid: add CCID device (device itself)
>
> Makefile.objs | 1 +
> configure | 12 +
> docs/usb-ccid.txt | 115 +++++
> hw/usb-ccid.c | 1376 ++++++++++++++++++++++++++++++++++++++++++++++++++++
> hw/vscard_common.h | 131 +++++
> 5 files changed, 1635 insertions(+), 0 deletions(-)
> create mode 100644 docs/usb-ccid.txt
> create mode 100644 hw/usb-ccid.c
> create mode 100644 hw/vscard_common.h
>
>
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2010-10-15 0:16 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <593949580.216281286900989465.JavaMail.root@zmail06.collab.prod.int.phx2.redhat.com>
2010-10-12 16:43 ` [Qemu-devel] [PATCH 0/2] usb-ccid device (v2) Alon Levy
2010-10-12 16:49 ` Anthony Liguori
2010-10-12 17:09 ` Alon Levy
2010-10-12 18:23 ` Anthony Liguori
2010-10-13 11:54 ` Alon Levy
2010-10-14 18:37 Robert Relyea
2010-10-14 18:52 ` Anthony Liguori
2010-10-14 22:03 ` Robert Relyea
2010-10-14 22:16 ` Anthony Liguori
2010-10-15 0:16 ` Robert Relyea
[not found] <1045788737.212361286898758903.JavaMail.root@zmail06.collab.prod.int.phx2.redhat.com>
2010-10-12 16:03 ` Alon Levy
2010-10-12 16:21 ` Anthony Liguori
-- strict thread matches above, loose matches on Subject: below --
2010-10-12 12:58 Alon Levy
2010-10-12 13:24 ` Anthony Liguori
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).