Skip to contentSkip to conversation

usb-ccid device (v2)

PATCH Robert Relyea 2 participants 5 messages Oct 14, 2010 – Oct 15, 2010

lore
Share & tools
lore
#0 lore raw
Quoted 8 lines · Anthony Liguori
Quoted 7 lines

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

#1 lore raw
Quoted 21 lines · Robert Relyea
Quoted 8 lines · Anthony Liguori
Quoted 7 lines

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.

Quoted 13 lines

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

Quoted 63 lines

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

#2 lore raw
Quoted 42 lines · Anthony Liguori
Quoted 21 lines · Robert Relyea
Quoted 8 lines · Anthony Liguori
Quoted 7 lines

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.

Quoted 13 lines

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.

Quoted 6 lines

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).

Quoted 3 lines

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.

Quoted 6 lines

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

Quoted 69 lines

Regards,

Anthony Liguori

Quoted 63 lines

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

#3 lore raw
Quoted 4 lines · Robert Relyea
Quoted 3 lines

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.

Quoted 1 line

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.

Quoted 3 lines
Quoted 2 lines

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.

Quoted 1 line

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

Quoted 71 lines

bob

Quoted 69 lines

Regards,

Anthony Liguori

Quoted 63 lines

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

#4 lore raw
Quoted 12 lines · Anthony Liguori
Quoted 11 lines · Robert Relyea
Quoted 11 lines

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.

Quoted 6 lines
Quoted 4 lines

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.

Quoted 5 lines

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...

Quoted 11 lines
Quoted 5 lines

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.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

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.

Quoted 5 lines
Quoted 2 lines

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.

Quoted 5 lines
Quoted 4 lines

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.

Quoted 7 lines

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