
Security News
npm ‘is’ Package Hijacked in Expanding Supply Chain Attack
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.
Libvirt event loop asynchronous implementation on Fibers. Based on libvirt-ruby and async. Allows to receive domain events. Allows to work with streams in asynchronous mode.
Add this line to your application's Gemfile:
gem 'libvirt_async'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install libvirt_async
LibvirtAsync.register_implementations!
must be called once per process before connecting to hypervisor.
We can subscribe for event from all hypervisor's domains
require 'libvirt_async'
LibvirtAsync.register_implementations!
connection = Libvirt::open('qemu+tcp://127.0.0.1:16509')
some_object = Object.new
connection.domain_event_register_any(
Libvirt::Connect::DOMAIN_EVENT_ID_LIFECYCLE,
->(connection, domain, event, detail, opaque) {
puts "LIFECYCLE event #{domain.uuid} #{event} #{detail}"
},
nil, # optional domain, can be omitted
some_object # will be an opaque in callback, can be omitted
)
Or we can subscribe on particular domain
require 'libvirt_async'
LibvirtAsync.register_implementations!
connection = Libvirt::open('qemu+tcp://127.0.0.1:16509')
domain = connection.list_all_domains.first
some_object = Object.new
connection.domain_event_register_any(
Libvirt::Connect::DOMAIN_EVENT_ID_LIFECYCLE,
->(connection, domain, event, detail, opaque) {
puts "LIFECYCLE event #{domain.uuid} #{event} #{detail}"
},
domain,
some_object # will be an opaque in callback, can be omitted
)
All available domain events:
connection.domain_event_register_any(
Libvirt::Connect::DOMAIN_EVENT_ID_REBOOT,
->(connection, domain, opaque) {
puts "REBOOT event #{domain.uuid}"
}
)
connection.domain_event_register_any(
Libvirt::Connect::DOMAIN_EVENT_ID_RTC_CHANGE,
->(connection, domain, utc_offset, opaque) {
puts "RTC_CHANGE event #{domain.uuid} #{utc_offset}"
}
)
connection.domain_event_register_any(
Libvirt::Connect::DOMAIN_EVENT_ID_WATCHDOG,
->(connection, domain, action, opaque) {
puts "WATCHDOG event #{domain.uuid} #{action}"
}
)
connection.domain_event_register_any(
Libvirt::Connect::DOMAIN_EVENT_ID_IO_ERROR,
->(connection, domain, src_path, dev_alias, action, opaque) {
puts "IO_ERROR event #{domain.uuid} #{src_path} #{dev_alias} #{action}"
}
)
connection.domain_event_register_any(
Libvirt::Connect::DOMAIN_EVENT_ID_IO_ERROR_REASON,
->(connection, domain, src_path, dev_alias, action, opaque) {
puts "IO_ERROR_REASON event #{domain.uuid} #{src_path} #{dev_alias} #{action}"
}
)
connection.domain_event_register_any(
Libvirt::Connect::DOMAIN_EVENT_ID_GRAPHICS,
->(connection, domain, phase, local, remote, auth_scheme, subject, opaque) {
puts "GRAPHICS event #{domain.uuid} #{phase} #{local} #{remote} #{auth_scheme} #{subject}"
}
)
require 'libvirt_async'
LibvirtAsync.register_implementations!
connection = Libvirt::open('qemu+tcp://127.0.0.1:16509')
domain = connection.list_all_domains.first
file = File.new("/screenshots/#{domain.uuid}.pnm", 'wb')
stream = LibvirtAsync::StreamRead.new(connection, file)
mime_type = domain.screenshot(stream.stream, 0)
puts "screenshot saving initiated mime_type=#{mime_type}"
# will start screenshot saving
stream.call do |success, reason, io|
# this block will be called asynchronously on complete or error
io.close
if success
puts "screenshot saved at #{io.path}"
else
puts "screenshot was not saved: #{reason}"
end
end
Logging.
require 'libvirt_async'
LibvirtAsync.use_logger!
LibvirtAsync.logger.level = Logger::Severity::DEBUG # for debugging
LibvirtAsync.start_debug_logging!(2) # will print implementations debug info to logger each 2 seconds.
Look at ruby-libvirt Documenation for further details.
Bug reports and pull requests are welcome on GitHub at https://github.com/senid231/libvirt_async. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.
$ bundle exec rake release
$ gem push pkg/libvirt_async-X.Y.Z.gem
The gem is available as open source under the terms of the MIT License.
Everyone interacting in the LibvirtAsync project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.
FAQs
Unknown package
We found that libvirt_async demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.
Security News
A critical flaw in the popular npm form-data package could allow HTTP parameter pollution, affecting millions of projects until patched versions are adopted.
Security News
Bun 1.2.19 introduces isolated installs for smoother monorepo workflows, along with performance boosts, new tooling, and key compatibility fixes.