mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-09 02:24:58 -06:00
char: avoid chardevice direct access
frontends should avoid accessing CharDriver struct where possible Signed-off-by: Anton Nefedov <anton.nefedov@virtuozzo.com> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <1499342940-56739-6-git-send-email-anton.nefedov@virtuozzo.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
7c44a2a9d1
commit
3065070153
24 changed files with 41 additions and 32 deletions
|
@ -322,7 +322,7 @@ static void passthru_apdu_from_guest(
|
|||
{
|
||||
PassthruState *card = PASSTHRU_CCID_CARD(base);
|
||||
|
||||
if (!qemu_chr_fe_get_driver(&card->cs)) {
|
||||
if (!qemu_chr_fe_backend_connected(&card->cs)) {
|
||||
printf("ccid-passthru: no chardev, discarding apdu length %d\n", len);
|
||||
return;
|
||||
}
|
||||
|
@ -343,7 +343,7 @@ static int passthru_initfn(CCIDCardState *base)
|
|||
|
||||
card->vscard_in_pos = 0;
|
||||
card->vscard_in_hdr = 0;
|
||||
if (qemu_chr_fe_get_driver(&card->cs)) {
|
||||
if (qemu_chr_fe_backend_connected(&card->cs)) {
|
||||
DPRINTF(card, D_INFO, "initing chardev\n");
|
||||
qemu_chr_fe_set_handlers(&card->cs,
|
||||
ccid_card_vscard_can_read,
|
||||
|
|
|
@ -484,13 +484,12 @@ static void usb_serial_realize(USBDevice *dev, Error **errp)
|
|||
{
|
||||
USBSerialState *s = USB_SERIAL_DEV(dev);
|
||||
Error *local_err = NULL;
|
||||
Chardev *chr = qemu_chr_fe_get_driver(&s->cs);
|
||||
|
||||
usb_desc_create_serial(dev);
|
||||
usb_desc_init(dev);
|
||||
dev->auto_attach = 0;
|
||||
|
||||
if (!chr) {
|
||||
if (!qemu_chr_fe_backend_connected(&s->cs)) {
|
||||
error_setg(errp, "Property chardev is required");
|
||||
return;
|
||||
}
|
||||
|
@ -505,7 +504,7 @@ static void usb_serial_realize(USBDevice *dev, Error **errp)
|
|||
usb_serial_event, NULL, s, NULL, true);
|
||||
usb_serial_handle_reset(dev);
|
||||
|
||||
if (chr->be_open && !dev->attached) {
|
||||
if (qemu_chr_fe_backend_open(&s->cs) && !dev->attached) {
|
||||
usb_device_attach(dev, &error_abort);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -273,10 +273,9 @@ static gboolean usbredir_write_unblocked(GIOChannel *chan, GIOCondition cond,
|
|||
static int usbredir_write(void *priv, uint8_t *data, int count)
|
||||
{
|
||||
USBRedirDevice *dev = priv;
|
||||
Chardev *chr = qemu_chr_fe_get_driver(&dev->cs);
|
||||
int r;
|
||||
|
||||
if (!chr->be_open) {
|
||||
if (!qemu_chr_fe_backend_open(&dev->cs)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1366,7 +1365,7 @@ static void usbredir_realize(USBDevice *udev, Error **errp)
|
|||
USBRedirDevice *dev = USB_REDIRECT(udev);
|
||||
int i;
|
||||
|
||||
if (!qemu_chr_fe_get_driver(&dev->cs)) {
|
||||
if (!qemu_chr_fe_backend_connected(&dev->cs)) {
|
||||
error_setg(errp, QERR_MISSING_PARAMETER, "chardev");
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue