qualcomm/qbox
Loading...
Searching...
No Matches
LibQemuPlugin Class Reference

Base class for QBox C++ plugins that bridge QEMU plugin callbacks. More...

#include <libqemu-plugin.h>

Inheritance diagram for LibQemuPlugin:
Collaboration diagram for LibQemuPlugin:

Public Member Functions

 LibQemuPlugin (const sc_core::sc_module_name &nm, qemu::LibQemu &inst)
void push_plugin_args (const std::string &plugin_path)
void shutdown_bridge ()
 Stop bridge dispatch and drain in-flight callbacks.
void * handle_as_userdata () const

Static Public Member Functions

template<typename Body>
static void dispatch_userdata (void *userdata, Body body)
 Run body on the live plugin instance, holding a refcount for the duration. No-op when the handle is null or alive==false.

Protected Attributes

cci::cci_param< uint64_t > m_id
qemu::LibQemu & m_inst
PluginHandle * m_handle

Detailed Description

Base class for QBox C++ plugins that bridge QEMU plugin callbacks.

Member Function Documentation

◆ dispatch_userdata()

template<typename Body>
void LibQemuPlugin::dispatch_userdata ( void * userdata,
Body body )
inlinestatic

Run body on the live plugin instance, holding a refcount for the duration. No-op when the handle is null or alive==false.

Every subclass callback funnels through here:

m_inst.plugin_api().qemu_plugin_register_vcpu_init_cb(
    m_id,
    [](int idx, void* userdata) {
        LibQemuPlugin::dispatch_userdata(userdata, [&](LibQemuPlugin* p) {
            static_cast<MyPlugin*>(p)->my_cb(idx);
        });
    },
    handle_as_userdata());

◆ shutdown_bridge()

void LibQemuPlugin::shutdown_bridge ( )
inline

Stop bridge dispatch and drain in-flight callbacks.

m_handle->alive's exchange is the once-guard. Flips the handle dead so new dispatches bail, then waits for the shared refcount to drain. The handle itself is intentionally leaked.


The documentation for this class was generated from the following file: