/* Notify the controller that an async packet is complete. This should only be called for packets previously deferred by returning USB_RET_ASYNC from handle_packet. */ void usb_packet_complete(USBDevice *dev, USBPacket *p) { USBEndpoint *ep = p->ep; int ret; usb_packet_check_state(p, USB_PACKET_ASYNC); assert(QTAILQ_FIRST(&ep->queue) == p); usb_packet_set_state(p, USB_PACKET_COMPLETE); QTAILQ_REMOVE(&ep->queue, p, queue); dev->port->ops->complete(dev->port, p); while (!QTAILQ_EMPTY(&ep->queue)) { p = QTAILQ_FIRST(&ep->queue); if (p->state == USB_PACKET_ASYNC) { break; } usb_packet_check_state(p, USB_PACKET_QUEUED); ret = usb_process_one(p); if (ret == USB_RET_ASYNC) { usb_packet_set_state(p, USB_PACKET_ASYNC); break; } p->result = ret; usb_packet_set_state(p, USB_PACKET_COMPLETE); QTAILQ_REMOVE(&ep->queue, p, queue); dev->port->ops->complete(dev->port, p); } }
static char *parse_initiator_name(const char *target) { QemuOptsList *list; QemuOpts *opts; const char *name = NULL; list = qemu_find_opts("iscsi"); if (!list) { return g_strdup("iqn.2008-11.org.linux-kvm"); } opts = qemu_opts_find(list, target); if (opts == NULL) { opts = QTAILQ_FIRST(&list->head); if (!opts) { return g_strdup("iqn.2008-11.org.linux-kvm"); } } name = qemu_opt_get(opts, "initiator-name"); if (!name) { return g_strdup("iqn.2008-11.org.linux-kvm"); } return g_strdup(name); }
/* Notify the controller that an async packet is complete. This should only be called for packets previously deferred by returning USB_RET_ASYNC from handle_packet. */ void usb_packet_complete(USBDevice *dev, USBPacket *p) { USBEndpoint *ep = p->ep; int ret; usb_packet_check_state(p, USB_PACKET_ASYNC); usb_packet_complete_one(dev, p); while (!QTAILQ_EMPTY(&ep->queue)) { p = QTAILQ_FIRST(&ep->queue); if (ep->halted) { /* Empty the queue on a halt */ p->result = USB_RET_REMOVE_FROM_QUEUE; dev->port->ops->complete(dev->port, p); continue; } if (p->state == USB_PACKET_ASYNC) { break; } usb_packet_check_state(p, USB_PACKET_QUEUED); ret = usb_process_one(p); if (ret == USB_RET_ASYNC) { usb_packet_set_state(p, USB_PACKET_ASYNC); break; } p->result = ret; usb_packet_complete_one(ep->dev, p); } }
static char *parse_initiator_name(const char *target) { QemuOptsList *list; QemuOpts *opts; const char *name = NULL; const char *iscsi_name = qemu_get_vm_name(); list = qemu_find_opts("iscsi"); if (list) { opts = qemu_opts_find(list, target); if (!opts) { opts = QTAILQ_FIRST(&list->head); } if (opts) { name = qemu_opt_get(opts, "initiator-name"); } } if (name) { return g_strdup(name); } else { return g_strdup_printf("iqn.2008-11.org.linux-kvm%s%s", iscsi_name ? ":" : "", iscsi_name ? iscsi_name : ""); } }
static void fw_cfg_bootsplash(FWCfgState *s) { const char *boot_splash_filename = NULL; const char *boot_splash_time = NULL; char *filename, *file_data; gsize file_size; int file_type; /* get user configuration */ QemuOptsList *plist = qemu_find_opts("boot-opts"); QemuOpts *opts = QTAILQ_FIRST(&plist->head); boot_splash_filename = qemu_opt_get(opts, "splash"); boot_splash_time = qemu_opt_get(opts, "splash-time"); /* insert splash time if user configurated */ if (boot_splash_time) { int64_t bst_val = qemu_opt_get_number(opts, "splash-time", -1); uint16_t bst_le16; /* validate the input */ if (bst_val < 0 || bst_val > 0xffff) { error_report("splash-time is invalid," "it should be a value between 0 and 65535"); exit(1); } /* use little endian format */ bst_le16 = cpu_to_le16(bst_val); fw_cfg_add_file(s, "etc/boot-menu-wait", g_memdup(&bst_le16, sizeof bst_le16), sizeof bst_le16); } /* insert splash file if user configurated */ if (boot_splash_filename) { filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, boot_splash_filename); if (filename == NULL) { error_report("failed to find file '%s'", boot_splash_filename); return; } /* loading file data */ file_data = read_splashfile(filename, &file_size, &file_type); if (file_data == NULL) { g_free(filename); return; } g_free(boot_splash_filedata); boot_splash_filedata = (uint8_t *)file_data; /* insert data */ if (file_type == JPG_FILE) { fw_cfg_add_file(s, "bootsplash.jpg", boot_splash_filedata, file_size); } else { fw_cfg_add_file(s, "bootsplash.bmp", boot_splash_filedata, file_size); } g_free(filename); } }
static void *qapi_dealloc_pop(QapiDeallocVisitor *qov) { StackEntry *e = QTAILQ_FIRST(&qov->stack); QObject *value; QTAILQ_REMOVE(&qov->stack, e, node); value = e->value; g_free(e); return value; }
static void s390_ipl_set_boot_menu(S390IPLState *ipl) { QemuOptsList *plist = qemu_find_opts("boot-opts"); QemuOpts *opts = QTAILQ_FIRST(&plist->head); uint8_t *flags = &ipl->qipl.qipl_flags; uint32_t *timeout = &ipl->qipl.boot_menu_timeout; const char *tmp; unsigned long splash_time = 0; if (!get_boot_device(0)) { if (boot_menu) { error_report("boot menu requires a bootindex to be specified for " "the IPL device"); } return; } switch (ipl->iplb.pbt) { case S390_IPL_TYPE_CCW: /* In the absence of -boot menu, use zipl parameters */ if (!qemu_opt_get(opts, "menu")) { *flags |= QIPL_FLAG_BM_OPTS_ZIPL; return; } break; case S390_IPL_TYPE_QEMU_SCSI: break; default: if (boot_menu) { error_report("boot menu is not supported for this device type"); } return; } if (!boot_menu) { return; } *flags |= QIPL_FLAG_BM_OPTS_CMD; tmp = qemu_opt_get(opts, "splash-time"); if (tmp && qemu_strtoul(tmp, NULL, 10, &splash_time)) { error_report("splash-time is invalid, forcing it to 0"); *timeout = 0; return; } if (splash_time > 0xffffffff) { error_report("splash-time is too large, forcing it to max value"); *timeout = 0xffffffff; return; } *timeout = cpu_to_be32(splash_time); }
void usb_packet_complete_one(USBDevice *dev, USBPacket *p) { USBEndpoint *ep = p->ep; assert(QTAILQ_FIRST(&ep->queue) == p); assert(p->result != USB_RET_ASYNC && p->result != USB_RET_NAK); if (p->result < 0 || (p->short_not_ok && (p->result < p->iov.size))) { ep->halted = true; } usb_packet_set_state(p, USB_PACKET_COMPLETE); QTAILQ_REMOVE(&ep->queue, p, queue); dev->port->ops->complete(dev->port, p); }
USBPacket *usb_ep_find_packet_by_id(USBDevice *dev, int pid, int ep, uint64_t id) { struct USBEndpoint *uep = usb_ep_get(dev, pid, ep); USBPacket *p; while ((p = QTAILQ_FIRST(&uep->queue)) != NULL) { if (p->id == id) { return p; } } return NULL; }
/* Notify the controller that an async packet is complete. This should only be called for packets previously deferred by returning USB_RET_ASYNC from handle_packet. */ void usb_packet_complete(USBDevice *dev, USBPacket *p) { USBEndpoint *ep = p->ep; int ret; usb_packet_check_state(p, USB_PACKET_ASYNC); assert(QTAILQ_FIRST(&ep->queue) == p); __usb_packet_complete(dev, p); while (!ep->halted && !QTAILQ_EMPTY(&ep->queue)) { p = QTAILQ_FIRST(&ep->queue); if (p->state == USB_PACKET_ASYNC) { break; } usb_packet_check_state(p, USB_PACKET_QUEUED); ret = usb_process_one(p); if (ret == USB_RET_ASYNC) { usb_packet_set_state(p, USB_PACKET_ASYNC); break; } p->result = ret; __usb_packet_complete(ep->dev, p); } }
static void bus_unparent(struct uc_struct *uc, Object *obj) { BusState *bus = BUS(uc, obj); BusChild *kid; while ((kid = QTAILQ_FIRST(&bus->children)) != NULL) { DeviceState *dev = kid->child; object_unparent(uc, OBJECT(dev)); } if (bus->parent) { QLIST_REMOVE(bus, sibling); bus->parent->num_child_bus--; bus->parent = NULL; } }
static void qlist_append_test(void) { QInt *qi; QList *qlist; QListEntry *entry; qi = qint_from_int(42); qlist = qlist_new(); qlist_append(qlist, qi); entry = QTAILQ_FIRST(&qlist->head); g_assert(entry != NULL); g_assert(entry->value == QOBJECT(qi)); // destroy doesn't exist yet QDECREF(qi); g_free(entry); g_free(qlist); }
static GenericList *qapi_dealloc_next_list(Visitor *v, GenericList **listp, Error **errp) { GenericList *list = *listp; QapiDeallocVisitor *qov = to_qov(v); StackEntry *e = QTAILQ_FIRST(&qov->stack); if (e && e->is_list_head) { e->is_list_head = false; return list; } if (list) { list = list->next; g_free(*listp); return list; } return NULL; }
/* Fetches the next PDU from the RE's xmit queue and returns the PDU's * length. 0 is returned if the queue is empty. */ static ssize_t fetch_pdu_from_re(struct llcp_pdu* llcp, struct nfc_re* re) { ssize_t len; assert(llcp); assert(re); if (QTAILQ_EMPTY(&re->xmit_q)) { return 0; } struct llcp_pdu_buf* buf; buf = QTAILQ_FIRST(&re->xmit_q); len = buf->len; memcpy(llcp, buf->pdu, len); QTAILQ_REMOVE(&re->xmit_q, buf, entry); llcp_free_pdu_buf(buf); return len; }
static void fw_cfg_reboot(FWCfgState *s) { const char *reboot_timeout = NULL; int64_t rt_val = -1; /* get user configuration */ QemuOptsList *plist = qemu_find_opts("boot-opts"); QemuOpts *opts = QTAILQ_FIRST(&plist->head); reboot_timeout = qemu_opt_get(opts, "reboot-timeout"); if (reboot_timeout) { rt_val = qemu_opt_get_number(opts, "reboot-timeout", -1); /* validate the input */ if (rt_val < 0 || rt_val > 0xffff) { error_report("reboot timeout is invalid," "it should be a value between 0 and 65535"); exit(1); } } fw_cfg_add_file(s, "etc/boot-fail-wait", g_memdup(&rt_val, 4), 4); }
static int parse_chap(struct iscsi_context *iscsi, const char *target) { QemuOptsList *list; QemuOpts *opts; const char *user = NULL; const char *password = NULL; list = qemu_find_opts("iscsi"); if (!list) { return 0; } opts = qemu_opts_find(list, target); if (opts == NULL) { opts = QTAILQ_FIRST(&list->head); if (!opts) { return 0; } } user = qemu_opt_get(opts, "user"); if (!user) { return 0; } password = qemu_opt_get(opts, "password"); if (!password) { error_report("CHAP username specified but no password was given"); return -1; } if (iscsi_set_initiator_username_pwd(iscsi, user, password)) { error_report("Failed to set initiator username and password"); return -1; } return 0; }
static void fw_cfg_reboot(FWCfgState *s) { int reboot_timeout = -1; char *p; const char *temp; /* get user configuration */ QemuOptsList *plist = qemu_find_opts("boot-opts"); QemuOpts *opts = QTAILQ_FIRST(&plist->head); if (opts != NULL) { temp = qemu_opt_get(opts, "reboot-timeout"); if (temp != NULL) { p = (char *)temp; reboot_timeout = strtol(p, (char **)&p, 10); } } /* validate the input */ if (reboot_timeout > 0xffff) { error_report("reboot timeout is larger than 65535, force it to 65535."); reboot_timeout = 0xffff; } fw_cfg_add_file(s, "etc/boot-fail-wait", g_memdup(&reboot_timeout, 4), 4); }
static void parse_header_digest(struct iscsi_context *iscsi, const char *target) { QemuOptsList *list; QemuOpts *opts; const char *digest = NULL; list = qemu_find_opts("iscsi"); if (!list) { return; } opts = qemu_opts_find(list, target); if (opts == NULL) { opts = QTAILQ_FIRST(&list->head); if (!opts) { return; } } digest = qemu_opt_get(opts, "header-digest"); if (!digest) { return; } if (!strcmp(digest, "CRC32C")) { iscsi_set_header_digest(iscsi, ISCSI_HEADER_DIGEST_CRC32C); } else if (!strcmp(digest, "NONE")) { iscsi_set_header_digest(iscsi, ISCSI_HEADER_DIGEST_NONE); } else if (!strcmp(digest, "CRC32C-NONE")) { iscsi_set_header_digest(iscsi, ISCSI_HEADER_DIGEST_CRC32C_NONE); } else if (!strcmp(digest, "NONE-CRC32C")) { iscsi_set_header_digest(iscsi, ISCSI_HEADER_DIGEST_NONE_CRC32C); } else { error_report("Invalid header-digest setting : %s", digest); } }
static size_t process_ptype_cc(struct nfc_re* re, const struct llcp_pdu* llcp, size_t len, uint8_t* consumed, struct llcp_pdu* rsp) { struct llcp_data_link* dl; dl = llcp_clear_data_link(re->llcp_dl[llcp->ssap] + llcp->dsap); assert(dl->status == LLCP_DATA_LINK_CONNECTING); dl->status = LLCP_DATA_LINK_CONNECTED; /* move DL's pending PDUs to global xmit queue */ while (!QTAILQ_EMPTY(&dl->xmit_q)) { struct llcp_pdu_buf* buf = QTAILQ_FIRST(&dl->xmit_q); QTAILQ_REMOVE(&dl->xmit_q, buf, entry); QTAILQ_INSERT_TAIL(&re->xmit_q, buf, entry); } update_last_saps(re, llcp->ssap, llcp->dsap); *consumed = sizeof(*llcp) + 1; return 0; }
static void fw_cfg_bootsplash(FWCfgState *s) { int boot_splash_time = -1; const char *boot_splash_filename = NULL; char *p; char *filename, *file_data; gsize file_size; int file_type; const char *temp; /* get user configuration */ QemuOptsList *plist = qemu_find_opts("boot-opts"); QemuOpts *opts = QTAILQ_FIRST(&plist->head); if (opts != NULL) { temp = qemu_opt_get(opts, "splash"); if (temp != NULL) { boot_splash_filename = temp; } temp = qemu_opt_get(opts, "splash-time"); if (temp != NULL) { p = (char *)temp; boot_splash_time = strtol(p, (char **)&p, 10); } } /* insert splash time if user configurated */ if (boot_splash_time >= 0) { /* validate the input */ if (boot_splash_time > 0xffff) { error_report("splash time is big than 65535, force it to 65535."); boot_splash_time = 0xffff; } /* use little endian format */ qemu_extra_params_fw[0] = (uint8_t)(boot_splash_time & 0xff); qemu_extra_params_fw[1] = (uint8_t)((boot_splash_time >> 8) & 0xff); fw_cfg_add_file(s, "etc/boot-menu-wait", qemu_extra_params_fw, 2); } /* insert splash file if user configurated */ if (boot_splash_filename != NULL) { filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, boot_splash_filename); if (filename == NULL) { error_report("failed to find file '%s'.", boot_splash_filename); return; } /* loading file data */ file_data = read_splashfile(filename, &file_size, &file_type); if (file_data == NULL) { g_free(filename); return; } if (boot_splash_filedata != NULL) { g_free(boot_splash_filedata); } boot_splash_filedata = (uint8_t *)file_data; boot_splash_filedata_size = file_size; /* insert data */ if (file_type == JPG_FILE) { fw_cfg_add_file(s, "bootsplash.jpg", boot_splash_filedata, boot_splash_filedata_size); } else { fw_cfg_add_file(s, "bootsplash.bmp", boot_splash_filedata, boot_splash_filedata_size); } g_free(filename); } }